Another thing that can be tried is: import threading a="" def input(): global a a = raw_input() T = threading.Thread(target=input) T.start() T.join(2) ## does the trick ...
I have not tested it but i guess should work. cheers, amit. On 1/12/06, Amit Khemka <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> 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. > -- ---- 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