This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: raw_input defers alarm signal
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: duplicate
Dependencies: Superseder: fix bug #685846: raw_input defers signals
View: 706406
Assigned To: Nosy List: georg.brandl, mbrierst, mwh, phr
Priority: normal Keywords:

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)
name = raw_input('Please enter your name within 5
seconds: ')

waits for input forever instead of getting the signal
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 

I'm 99% sure this is readline's fault.

You might be able to test this by hiding the
from the interpreter.
msg14601 - (view) Author: Michael Stone (mbrierst) Date: 2003-03-19 17:51
Logged In: YES 

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
Date User Action Args
2022-04-10 16:06:47adminsetgithub: 37979
2007-09-06 15:13:23georg.brandlsetstatus: open -> closed
resolution: duplicate
superseder: fix bug #685846: raw_input defers signals
messages: + msg55697
nosy: + georg.brandl
2003-02-13 10:11:27phrcreate