本文整理汇总了Python中faulthandler.dump_traceback_later方法的典型用法代码示例。如果您正苦于以下问题:Python faulthandler.dump_traceback_later方法的具体用法?Python faulthandler.dump_traceback_later怎么用?Python faulthandler.dump_traceback_later使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faulthandler
的用法示例。
在下文中一共展示了faulthandler.dump_traceback_later方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_runtest_protocol
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def pytest_runtest_protocol(item):
timeout = float(item.config.getini("faulthandler_timeout") or 0.0)
if timeout > 0:
import faulthandler
stderr = item.config.fault_handler_stderr
faulthandler.dump_traceback_later(timeout, file=stderr)
try:
yield
finally:
faulthandler.cancel_dump_traceback_later()
else:
yield
示例2: pytest_runtest_protocol
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def pytest_runtest_protocol(self, item: Item) -> Generator[None, None, None]:
timeout = self.get_timeout_config_value(item.config)
stderr = item.config._store[fault_handler_stderr_key]
if timeout > 0 and stderr is not None:
import faulthandler
faulthandler.dump_traceback_later(timeout, file=stderr)
try:
yield
finally:
faulthandler.cancel_dump_traceback_later()
else:
yield
示例3: test_stderr_None
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def test_stderr_None(self):
# Issue #21497: provide an helpful error if sys.stderr is None,
# instead of just an attribute error: "None has no attribute fileno".
with self.check_stderr_none():
faulthandler.enable()
with self.check_stderr_none():
faulthandler.dump_traceback()
if hasattr(faulthandler, 'dump_traceback_later'):
with self.check_stderr_none():
faulthandler.dump_traceback_later(1e-3)
if hasattr(faulthandler, "register"):
with self.check_stderr_none():
faulthandler.register(signal.SIGUSR1)
示例4: setUpClass
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def setUpClass(cls):
cls.orig_handler = signal.signal(signal.SIGALRM, lambda *args: None)
signal.setitimer(signal.ITIMER_REAL, cls.signal_delay,
cls.signal_period)
# Issue #25277: Use faulthandler to try to debug a hang on FreeBSD
if hasattr(faulthandler, 'dump_traceback_later'):
faulthandler.dump_traceback_later(10 * 60, exit=True)
示例5: setUp
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def setUp(self):
super().setUp()
# Create NTEST tests doing nothing
self.tests = [self.create_test() for index in range(self.NTEST)]
self.python_args = ['-Wd', '-E', '-bb']
self.regrtest_args = ['-uall', '-rwW',
'--testdir=%s' % self.tmptestdir]
if hasattr(faulthandler, 'dump_traceback_later'):
self.regrtest_args.extend(('--timeout', '3600', '-j4'))
if sys.platform == 'win32':
self.regrtest_args.append('-n')
示例6: test_stderr_None
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def test_stderr_None(self):
# Issue #21497: provide a helpful error if sys.stderr is None,
# instead of just an attribute error: "None has no attribute fileno".
with self.check_stderr_none():
faulthandler.enable()
with self.check_stderr_none():
faulthandler.dump_traceback()
if hasattr(faulthandler, 'dump_traceback_later'):
with self.check_stderr_none():
faulthandler.dump_traceback_later(1e-3)
if hasattr(faulthandler, "register"):
with self.check_stderr_none():
faulthandler.register(signal.SIGUSR1)
示例7: setUp
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def setUp(self):
self.signals = 0
self.orig_handler = signal.signal(signal.SIGALRM, self.sighandler)
signal.setitimer(signal.ITIMER_REAL, self.signal_delay,
self.signal_period)
# Use faulthandler as watchdog to debug when a test hangs
# (timeout of 10 minutes)
if hasattr(faulthandler, 'dump_traceback_later'):
faulthandler.dump_traceback_later(10 * 60, exit=True,
file=sys.__stderr__)
示例8: check_dump_traceback_later
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def check_dump_traceback_later(self, repeat=False, cancel=False, loops=1,
*, filename=None, fd=None):
"""
Check how many times the traceback is written in timeout x 2.5 seconds,
or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending
on repeat and cancel options.
Raise an error if the output doesn't match the expect format.
"""
timeout_str = str(datetime.timedelta(seconds=TIMEOUT))
code = """
import faulthandler
import time
import sys
timeout = {timeout}
repeat = {repeat}
cancel = {cancel}
loops = {loops}
filename = {filename!r}
fd = {fd}
def func(timeout, repeat, cancel, file, loops):
for loop in range(loops):
faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file)
if cancel:
faulthandler.cancel_dump_traceback_later()
time.sleep(timeout * 5)
faulthandler.cancel_dump_traceback_later()
if filename:
file = open(filename, "wb")
elif fd is not None:
file = sys.stderr.fileno()
else:
file = None
func(timeout, repeat, cancel, file, loops)
if filename:
file.close()
"""
code = code.format(
timeout=TIMEOUT,
repeat=repeat,
cancel=cancel,
loops=loops,
filename=filename,
fd=fd,
)
trace, exitcode = self.get_output(code, filename)
trace = '\n'.join(trace)
if not cancel:
count = loops
if repeat:
count *= 2
header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str
regex = expected_traceback(17, 26, header, min_count=count)
self.assertRegex(trace, regex)
else:
self.assertEqual(trace, '')
self.assertEqual(exitcode, 0)
示例9: _check_dump_traceback_later
# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import dump_traceback_later [as 别名]
def _check_dump_traceback_later(self, repeat, cancel, filename, loops):
"""
Check how many times the traceback is written in timeout x 2.5 seconds,
or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending
on repeat and cancel options.
Raise an error if the output doesn't match the expect format.
"""
timeout_str = str(datetime.timedelta(seconds=TIMEOUT))
code = """
import faulthandler
import time
def func(timeout, repeat, cancel, file, loops):
for loop in range(loops):
faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file)
if cancel:
faulthandler.cancel_dump_traceback_later()
time.sleep(timeout * 5)
faulthandler.cancel_dump_traceback_later()
timeout = {timeout}
repeat = {repeat}
cancel = {cancel}
loops = {loops}
if {has_filename}:
file = open({filename}, "wb")
else:
file = None
func(timeout, repeat, cancel, file, loops)
if file is not None:
file.close()
"""
code = code.format(
timeout=TIMEOUT,
repeat=repeat,
cancel=cancel,
loops=loops,
has_filename=bool(filename),
filename=repr(filename),
)
trace, exitcode = self.get_output(code, filename)
trace = '\n'.join(trace)
if not cancel:
count = loops
if repeat:
count *= 2
header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str
regex = expected_traceback(9, 20, header, min_count=count)
self.assertRegex(trace, regex)
else:
self.assertEqual(trace, '')
self.assertEqual(exitcode, 0)