You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I may have found a bug in SIGALRM handling in Python3.5. I've not been able to reproduce the same issue in Python2.7 or 3.4. Here's a simple example that illustrates the issue (which I'm able to reproduce on OS X 10.11.3 El Capitan and Ubuntu 14.04):
defhandler(signum, frame):
print('Signal handler called with signal %s'%signum)
# Set the signal handler and a 1-second alarmsignal.signal(signal.SIGALRM, handler)
signal.alarm(1)
# We should not actually sleep for 10 secondstime.sleep(10)
signal.alarm(0)
$ time python2 alarm.py
Signal handler called with signal 14
python2 alarm.py 0.04s user 0.02s system 5% cpu 1.075 total
$ time python3.4 alarm.py
Signal handler called with signal 14
python3.4 alarm.py 0.07s user 0.01s system 7% cpu 1.092 total
$ time python3.5 alarm.py
Signal handler called with signal 14
python3.5 alarm.py 0.09s user 0.02s system 1% cpu 10.115 total
Note that when run under python3.5, the program does not exit until 10 seconds have passed.
ryanpetrellomannequin
changed the title
SIGALRM fails to interrupt time.sleep() call on Python 3.6
SIGALRM fails to interrupt time.sleep() call on Python 3.5
Oct 18, 2016
If you make your signal handler raise an exception, it will interrupt the sleep() call most of the time. But if the signal happens to be received just before the sleep() call is about to be entered, the handler will only be run when the underlying OS sleep() call returns 10 s later.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: