mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
faulthandler: dump all threads by default
* Set the default value of all_threads arguments to True * Py_FatalError() dumps all threads, instead of only the current thread Dump only the current thread is not reliable. In some cases, Python is unable to retrieve the state of the current thread and so is unable to dump the traceback. faulthandler keeps a reference to the interpreter and so is always able to dump the traceback of all threads.
This commit is contained in:
parent
c925617b54
commit
7bba62fd68
4 changed files with 24 additions and 23 deletions
|
@ -75,7 +75,7 @@ class FaultHandlerTests(unittest.TestCase):
|
|||
return output.splitlines(), exitcode
|
||||
|
||||
def check_fatal_error(self, code, line_number, name_regex,
|
||||
filename=None, all_threads=False, other_regex=None):
|
||||
filename=None, all_threads=True, other_regex=None):
|
||||
"""
|
||||
Check that the fault handler for fatal errors is enabled and check the
|
||||
traceback from the child process output.
|
||||
|
@ -204,15 +204,15 @@ faulthandler._read_null()
|
|||
'(?:Segmentation fault|Bus error)',
|
||||
filename=filename)
|
||||
|
||||
def test_enable_threads(self):
|
||||
def test_enable_single_thread(self):
|
||||
self.check_fatal_error("""
|
||||
import faulthandler
|
||||
faulthandler.enable(all_threads=True)
|
||||
faulthandler.enable(all_threads=False)
|
||||
faulthandler._read_null()
|
||||
""".strip(),
|
||||
3,
|
||||
'(?:Segmentation fault|Bus error)',
|
||||
all_threads=True)
|
||||
all_threads=False)
|
||||
|
||||
def test_disable(self):
|
||||
code = """
|
||||
|
@ -252,9 +252,9 @@ import faulthandler
|
|||
def funcB():
|
||||
if {has_filename}:
|
||||
with open({filename}, "wb") as fp:
|
||||
faulthandler.dump_traceback(fp)
|
||||
faulthandler.dump_traceback(fp, all_threads=False)
|
||||
else:
|
||||
faulthandler.dump_traceback()
|
||||
faulthandler.dump_traceback(all_threads=False)
|
||||
|
||||
def funcA():
|
||||
funcB()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue