Issue 685846: raw_input defers alarm signal (original) (raw)

Created on 2003-02-13 10:11 by phr, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (4)
msg14599 - (view) Author: paul rubin (phr) Date: 2003-02-13 10:11
import signal def handle(a,b): print "received signal" signal.signal(signal.SIGALRM, handle) signal.alarm(5) name = raw_input('Please enter your name within 5 seconds: ') waits for input forever instead of getting the signal thrown after 5 seconds. If you wait more than 5 seconds before typing your name, the signal does get handled after you finally enter your input. The workaround of calling sys.stdin.readline() instead of raw_input does the right thing, so something is funny about the raw_input function.
msg14600 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-02-13 11:46
Logged In: YES user_id=6656 I'm 99% sure this is readline's fault. You might be able to test this by hiding the readline.so from the interpreter.
msg14601 - (view) Author: Michael Stone (mbrierst) Date: 2003-03-19 17:51
Logged In: YES user_id=670441 This isn't just a readline problem, it's consistent whether or not readline is used. Patch #706406 attempts to fix this problem in a reasonable manner, but it may not be possible to fix perfectly. Signals always seem pretty hopeless to get really right, and python hardly tries most of the time. (Only handling them in the main thread...) I think raw_input really doesn't WANT to just give up when receiving a signal, so the patch has it give up only when the signal handler throws an exception.
msg55697 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-06 15:13
Setting patch as superseder
History
Date User Action Args
2022-04-10 16:06:47 admin set github: 37979
2007-09-06 15:13:23 georg.brandl set status: open -> closedresolution: duplicatesuperseder: fix bug #685846: raw_input defers signalsmessages: + nosy: + georg.brandl
2003-02-13 10:11:27 phr create