I got the signal to work on linux with sys.stdin.readline() but the
process timeout after x seconds even when I input something. Is there
a way to close the signal after getting a correct input from the
console window?
Thanks
Thierry
--
http://mail.python.org/mailman/listinfo/python-list
Another thing that can be tried is:
import threading
a=""
def input():
global a
a = raw_input()
T = threading.Thread(target=input)
T.start()
T.join(2) ## does the trick
...
I have not tested it but i guess should work.
cheers,
amit.
On 1/12/06, Amit Khemka <[EMAIL PROTECTED]>
Amit Khemka <[EMAIL PROTECTED]> writes:
> import signal
> TIMEOUT = 5 # number of seconds your want for timeout
> signal.signal(signal.SIGALRM, input)
> signal.alarm(TIMEOUT)
>
> def input():
> try:
>foo = raw_input()
>return foo
> except:
> # timeout
> return
This doesn't work with
I tried it on "Python 2.4.1" on '2.6.11-1.1369_FC4smp with gcc version
4.0.0' .. which works fine .. may be it could be an issue with some
other combinations ..
cheers,
amit
On 12 Jan 2006 07:35:57 -0800, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> Amit Khemka <[EMAIL PROTECTED]> writes:
its "Python 2.4.1" .. on linux
On 12 Jan 2006 06:34:08 -0800, Thierry Lam <[EMAIL PROTECTED]> wrote:
> Is there a windows equivalent for that solution?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Endless the world's turn, endless the sun's spinning
Endless the quest;
I
[Thierry Lam]
[to do with a Win32 equivalent to the SIGALRM
interruption of a raw_input]
| Is there a windows equivalent for that solution?
Nothing so straightforward. Depends how hard you want
to try. A couple of past threads on pretty much the
exact same issue offer no equivalent solution.
Is there a windows equivalent for that solution?
--
http://mail.python.org/mailman/listinfo/python-list
Which Python version are you using? I'm getting the following error
with Python 2.3.4:
Traceback (most recent call last):
File "C:\home\pciroot\vcur\sdk\tools\inter.py", line 32, in ?
signal.signal(signal.SIGALRM, input)
AttributeError: 'module' object has no attribute 'SIGALRM'
Thierry
-
One way would be to use 'signal' s ... something like this should work
import signal
TIMEOUT = 5 # number of seconds your want for timeout
signal.signal(signal.SIGALRM, input)
signal.alarm(TIMEOUT)
def input():
try:
foo = raw_input()
return foo
except:
# timeout
return
cheers,
amit.