Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14)

Unified Diff: Lib/test/regrtest.py

Issue 12073: regrtest: use faulthandler to dump the tracebacks on SIGUSR1
Patch Set: Created 2 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -160,21 +160,28 @@ To enable all resources except one, use
example, to run all the tests except for the gui tests, give the
option '-uall,-gui'.
"""
+USAGE_SIGUSR1 = """
+You can send a SIGUSR1 signal to display the tracebacks of the current threads.
+Note that sending a signal may interrupt a system call in progress and thus
+interfere with the tests, so only do it if a test hangs and you want to know
+where.
+"""
import builtins
+import errno
import faulthandler
import getopt
+import io
import json
import os
import random
import re
-import io
+import signal
import sys
import time
-import errno
import traceback
+import unittest
import warnings
-import unittest
from inspect import isabstract
import tempfile
import platform
@@ -268,6 +275,8 @@ def main(tests=None, testdir=None, verbo
# Display the Python traceback fatal errors (e.g. segfault)
faulthandler.enable(all_threads=True)
+ if hasattr(signal, 'SIGUSR1'):
+ faulthandler.register(signal.SIGUSR1)
if hasattr(faulthandler, 'dump_tracebacks_later'):
timeout = 60*60
@@ -297,7 +306,10 @@ def main(tests=None, testdir=None, verbo
start = None
for o, a in opts:
if o in ('-h', '--help'):
- print(__doc__)
+ usage = __doc__
+ if hasattr(signal, 'SIGUSR1'):
+ usage += USAGE_SIGUSR1
+ print(usage)
return
elif o in ('-v', '--verbose'):
verbose += 1
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7