mirror of
https://github.com/python/cpython.git
synced 2025-12-11 03:20:01 +00:00
test_faulthandler: use a longer sleep (2.5 sec instead of 1.3 sec) in
_check_dump_tracebacks_later() to avoid failures if the system is slow.
This commit is contained in:
parent
ebbbdafd87
commit
301f3f093c
1 changed files with 7 additions and 6 deletions
|
|
@ -29,12 +29,13 @@ else:
|
||||||
except (ValueError, resource_error):
|
except (ValueError, resource_error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def expected_traceback(lineno1, lineno2, header, count=1):
|
def expected_traceback(lineno1, lineno2, header, min_count=1):
|
||||||
regex = header
|
regex = header
|
||||||
regex += ' File "<string>", line %s in func\n' % lineno1
|
regex += ' File "<string>", line %s in func\n' % lineno1
|
||||||
regex += ' File "<string>", line %s in <module>' % lineno2
|
regex += ' File "<string>", line %s in <module>' % lineno2
|
||||||
if count != 1:
|
if 1 < min_count:
|
||||||
regex = (regex + '\n') * (count - 1) + regex
|
return '^' + (regex + '\n') * (min_count - 1) + regex
|
||||||
|
else:
|
||||||
return '^' + regex + '$'
|
return '^' + regex + '$'
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|
@ -371,7 +372,7 @@ def func(timeout, repeat, cancel, file, loops):
|
||||||
faulthandler.dump_tracebacks_later(timeout, repeat=repeat, file=file)
|
faulthandler.dump_tracebacks_later(timeout, repeat=repeat, file=file)
|
||||||
if cancel:
|
if cancel:
|
||||||
faulthandler.cancel_dump_tracebacks_later()
|
faulthandler.cancel_dump_tracebacks_later()
|
||||||
time.sleep(timeout * 2.5)
|
time.sleep(timeout * 5)
|
||||||
faulthandler.cancel_dump_tracebacks_later()
|
faulthandler.cancel_dump_tracebacks_later()
|
||||||
|
|
||||||
timeout = {timeout}
|
timeout = {timeout}
|
||||||
|
|
@ -402,7 +403,7 @@ if file is not None:
|
||||||
if repeat:
|
if repeat:
|
||||||
count *= 2
|
count *= 2
|
||||||
header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+:\n' % timeout_str
|
header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+:\n' % timeout_str
|
||||||
regex = expected_traceback(9, 20, header, count=count)
|
regex = expected_traceback(9, 20, header, min_count=count)
|
||||||
self.assertRegex(trace, regex)
|
self.assertRegex(trace, regex)
|
||||||
else:
|
else:
|
||||||
self.assertEqual(trace, '')
|
self.assertEqual(trace, '')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue