From: Victor Stinner Date: Wed, 13 Jul 2011 21:47:21 +0000 (+0200) Subject: Issue #12550: regrtest displays the Python traceback on SIGALRM or SIGUSR1 X-Git-Tag: v3.3.0a1~1915 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb41cda8e302279821433d862dfe80af8eea4597;p=thirdparty%2FPython%2Fcpython.git Issue #12550: regrtest displays the Python traceback on SIGALRM or SIGUSR1 --- diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 1426c3edbe9e..528f46a18e70 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -172,6 +172,7 @@ import os import platform import random import re +import signal import sys import sysconfig import tempfile @@ -266,9 +267,18 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, on the command line. """ - # Display the Python traceback fatal errors (e.g. segfault) + # Display the Python traceback on fatal errors (e.g. segfault) faulthandler.enable(all_threads=True) + # Display the Python traceback on SIGALRM or SIGUSR1 signal + signals = [] + if hasattr(signal, 'SIGALRM'): + signals.append(signal.SIGALRM) + if hasattr(signal, 'SIGUSR1'): + signals.append(signal.SIGUSR1) + for signum in signals: + faulthandler.register(signum, chain=True) + replace_stdout() support.record_original_stdout(sys.stdout)