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. On 11 Jan 2006 13:24:34 -0800, Thierry Lam <[EMAIL PROTECTED]> wrote: > I can use the python function raw_input() to read any input from the > user but how can I add a timeout so that my program exits after x > period of time when no input has been entered. > > Thierry > > -- > 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. -- http://mail.python.org/mailman/listinfo/python-list