summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-10-17 09:38:37 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-10-17 09:38:37 (GMT)
commitd44500affecd88dade4024f3a6d3efa52bd1a026 (patch)
treee04a201e7e6ba4f9d7f8adb5a0c30d814db404e9
parent3da240fd01e02a31e516847ba865a9f56d7cfcbc (diff)
downloadcpython-d44500affecd88dade4024f3a6d3efa52bd1a026.zip
cpython-d44500affecd88dade4024f3a6d3efa52bd1a026.tar.gz
cpython-d44500affecd88dade4024f3a6d3efa52bd1a026.tar.bz2
Try to print a backtrace of wedged child process in test.
-rw-r--r--Lib/test/_test_multiprocessing.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 910cfa9..ac1b2a7 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -300,6 +300,9 @@ class _TestProcess(BaseTestCase):
p.terminate()
if hasattr(signal, 'alarm'):
+ # On the Gentoo buildbot waitpid() often seems to block forever.
+ # We use alarm() to interrupt it if it blocks for too long, and
+ # then try to print a backtrace for the child process using gdb.
def handler(*args):
raise RuntimeError('join took too long: %s' % p)
old_handler = signal.signal(signal.SIGALRM, handler)
@@ -307,6 +310,16 @@ class _TestProcess(BaseTestCase):
signal.alarm(10)
self.assertEqual(join(), None)
signal.alarm(0)
+ except RuntimeError:
+ print('os.waitpid() =', os.waitpid(p.pid, os.WNOHANG))
+ import subprocess
+ p = subprocess.Popen(['gdb', sys.executable, str(p.pid)],
+ stdin=subprocess.PIPE)
+ try:
+ p.communicate(b'bt 50', timeout=10)
+ except subprocess.TimeoutExpired:
+ p.kill()
+ raise
finally:
signal.signal(signal.SIGALRM, old_handler)
else: