mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Add enough debugging information to diagnose failures where the
HandlerBException is ignored, and fix one such problem, where it was thrown during the __del__ method of the previous Popen object. We may want to find a better way of printing verbose information so it's not spammy when the test passes.
This commit is contained in:
parent
5a4d66824a
commit
ee76777846
1 changed files with 14 additions and 5 deletions
|
|
@ -48,16 +48,21 @@ class InterProcessSignalTests(unittest.TestCase):
|
||||||
if self.using_gc:
|
if self.using_gc:
|
||||||
gc.enable()
|
gc.enable()
|
||||||
|
|
||||||
def handlerA(self, *args):
|
def format_frame(self, frame, limit=None):
|
||||||
|
return ''.join(traceback.format_stack(frame, limit=limit))
|
||||||
|
|
||||||
|
def handlerA(self, signum, frame):
|
||||||
self.a_called = True
|
self.a_called = True
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print "handlerA invoked", args
|
print "handlerA invoked from signal %s at:\n%s" % (
|
||||||
|
signum, self.format_frame(frame, limit=1))
|
||||||
|
|
||||||
def handlerB(self, *args):
|
def handlerB(self, signum, frame):
|
||||||
self.b_called = True
|
self.b_called = True
|
||||||
if test_support.verbose:
|
if test_support.verbose:
|
||||||
print "handlerB invoked", args
|
print "handlerB invoked from signal %s at:\n%s" % (
|
||||||
raise HandlerBCalled(*args)
|
signum, self.format_frame(frame, limit=1))
|
||||||
|
raise HandlerBCalled(signum, self.format_frame(frame))
|
||||||
|
|
||||||
def wait(self, child):
|
def wait(self, child):
|
||||||
"""Wait for child to finish, ignoring EINTR."""
|
"""Wait for child to finish, ignoring EINTR."""
|
||||||
|
|
@ -95,6 +100,10 @@ class InterProcessSignalTests(unittest.TestCase):
|
||||||
self.assertFalse(self.b_called)
|
self.assertFalse(self.b_called)
|
||||||
self.a_called = False
|
self.a_called = False
|
||||||
|
|
||||||
|
# Make sure the signal isn't delivered while the previous
|
||||||
|
# Popen object is being destroyed, because __del__ swallows
|
||||||
|
# exceptions.
|
||||||
|
del child
|
||||||
try:
|
try:
|
||||||
child = subprocess.Popen(['kill', '-USR1', str(pid)])
|
child = subprocess.Popen(['kill', '-USR1', str(pid)])
|
||||||
# This wait should be interrupted by the signal's exception.
|
# This wait should be interrupted by the signal's exception.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue