George Slavin added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27889>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to