mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-31234: Add support.join_thread() helper (#3587)
join_thread() joins a thread but raises an AssertionError if the thread is still alive after timeout seconds.
This commit is contained in:
parent
167cbde50a
commit
b9b69003d9
9 changed files with 50 additions and 65 deletions
|
@ -58,10 +58,7 @@ class BlockingTestMixin:
|
|||
block_func)
|
||||
return self.result
|
||||
finally:
|
||||
thread.join(10) # make sure the thread terminates
|
||||
if thread.is_alive():
|
||||
self.fail("trigger function '%r' appeared to not return" %
|
||||
trigger_func)
|
||||
support.join_thread(thread, 10) # make sure the thread terminates
|
||||
|
||||
# Call this instead if block_func is supposed to raise an exception.
|
||||
def do_exceptional_blocking_test(self,block_func, block_args, trigger_func,
|
||||
|
@ -77,10 +74,7 @@ class BlockingTestMixin:
|
|||
self.fail("expected exception of kind %r" %
|
||||
expected_exception_class)
|
||||
finally:
|
||||
thread.join(10) # make sure the thread terminates
|
||||
if thread.is_alive():
|
||||
self.fail("trigger function '%r' appeared to not return" %
|
||||
trigger_func)
|
||||
support.join_thread(thread, 10) # make sure the thread terminates
|
||||
if not thread.startedEvent.is_set():
|
||||
self.fail("trigger thread ended but event never set")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue