Message274533
In case anyone else sees this thread, here's my trimmed down script to repro the issue:
#!/usr/bin/env python2
import threading as mt
import signal
import time
import os
def sigusr2_handler(signum, frame):
raise RuntimeError('caught sigusr2')
signal.signal(signal.SIGUSR2, sigusr2_handler)
def sub(pid):
time.sleep(1)
os.kill(pid, signal.SIGUSR2)
try:
t = mt.Thread(target=sub, args=[os.getpid()])
t.start()
time.sleep(500)
except Exception as e:
print('except: %s' % e)
else:
print('unexcepted')
finally:
t.join()
When I run the above, I get the repro after hundreds of iterations. From these results, it appears there is no guarentee that the signal handler will run before the main thread continues execution at the time.sleep(500) line. This would explain why we advance to the else clause before the exception is raised. |
|
Date |
User |
Action |
Args |
2016-09-06 07:20:51 | gslavin | set | recipients:
+ gslavin, eryksun, Andre Merzky |
2016-09-06 07:20:51 | gslavin | set | messageid: <1473146451.94.0.824500696767.issue27889@psf.upfronthosting.co.za> |
2016-09-06 07:20:51 | gslavin | link | issue27889 messages |
2016-09-06 07:20:51 | gslavin | create | |
|