Timeout at command prompt
Paul Rubin
http
Thu Jan 12 10:35:57 EST 2006
Amit Khemka <khemkaamit at gmail.com> 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 raw_input under linux, maybe because the
readline lib is snagging the timer interrupt or something. Use
sys.stdin.readline instead. SF bug:
http://sourceforge.net/tracker/index.php?func=detail&aid=685846&group_id=5470&atid=105470
More information about the Python-list
mailing list