Keyboard input with timeout in Python

Posted by J. Pablo Fernández on Stack Overflow See other posts from Stack Overflow or by J. Pablo Fernández
Published on 2009-08-26T15:19:05Z Indexed on 2010/05/25 11:21 UTC
Read the original article Hit count: 298

Filed under:
|
|

How would you prompt the user for some input but timing out after N seconds?

Google is pointing to a mail thread about it at http://mail.python.org/pipermail/python-list/2006-January/533215.html but it seems not to work. The statement in which the timeout happens, no matter whether it is a sys.input.readline or timer.sleep(), I always get:

<type 'exceptions.TypeError'>: [raw_]input expected at most 1 arguments, got 2

which somehow the except fails to catch.

© Stack Overflow or respective owner

Related posts about python

Related posts about timeout