mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +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
|
@ -791,13 +791,10 @@ class TestSMTPServer(smtpd.SMTPServer):
|
|||
to terminate.
|
||||
"""
|
||||
self.close()
|
||||
self._thread.join(timeout)
|
||||
support.join_thread(self._thread, timeout)
|
||||
self._thread = None
|
||||
asyncore.close_all(map=self._map, ignore_all=True)
|
||||
|
||||
alive = self._thread.is_alive()
|
||||
self._thread = None
|
||||
if alive:
|
||||
self.fail("join() timed out")
|
||||
|
||||
class ControlMixin(object):
|
||||
"""
|
||||
|
@ -847,11 +844,8 @@ class ControlMixin(object):
|
|||
"""
|
||||
self.shutdown()
|
||||
if self._thread is not None:
|
||||
self._thread.join(timeout)
|
||||
alive = self._thread.is_alive()
|
||||
support.join_thread(self._thread, timeout)
|
||||
self._thread = None
|
||||
if alive:
|
||||
self.fail("join() timed out")
|
||||
self.server_close()
|
||||
self.ready.clear()
|
||||
|
||||
|
@ -2892,9 +2886,7 @@ class ConfigDictTest(BaseTest):
|
|||
finally:
|
||||
t.ready.wait(2.0)
|
||||
logging.config.stopListening()
|
||||
t.join(2.0)
|
||||
if t.is_alive():
|
||||
self.fail("join() timed out")
|
||||
support.join_thread(t, 2.0)
|
||||
|
||||
def test_listen_config_10_ok(self):
|
||||
with support.captured_stdout() as output:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue