Timeout at command prompt

Amit Khemka khemkaamit at gmail.com
Thu Jan 12 10:49:22 EST 2006


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 <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
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
----
Endless the world's turn, endless the sun's spinning
Endless the quest;
I turn again, back to my own beginning,
And here, find rest.



More information about the Python-list mailing list