[Python-checkins] cpython: Try to print a backtrace of wedged child process in test.
richard.oudkerk
python-checkins at python.org
Thu Oct 17 11:40:47 CEST 2013
http://hg.python.org/cpython/rev/6f4806323208
changeset: 86391:6f4806323208
user: Richard Oudkerk <shibturn at gmail.com>
date: Thu Oct 17 10:38:37 2013 +0100
summary:
Try to print a backtrace of wedged child process in test.
files:
Lib/test/_test_multiprocessing.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -300,6 +300,9 @@
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 @@
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:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list