How to timeout when waiting for raw_input from user ?

Paul Rubin no.email at nospam.invalid
Sat Dec 5 00:23:23 EST 2009


northof40 <shearichard at gmail.com> writes:
> I'm thinking of some logic where a raw_input call is executed and then
> if more than X seconds elapses before the prompt is replied to the
> process writes a message "Sorry too slow" (or similar).

The simplest way to do this is with the alarm function and a signal
handler.  See the docs for the signal module.




More information about the Python-list mailing list