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.

Author gslavin
Recipients Andre Merzky, eryksun, gslavin
Date 2016-09-06.07:20:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473146451.94.0.824500696767.issue27889@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-09-06 07:20:51gslavinsetrecipients: + gslavin, eryksun, Andre Merzky
2016-09-06 07:20:51gslavinsetmessageid: <1473146451.94.0.824500696767.issue27889@psf.upfronthosting.co.za>
2016-09-06 07:20:51gslavinlinkissue27889 messages
2016-09-06 07:20:51gslavincreate