bpo-40275: Adding threading_helper submodule in test.support (GH-20263)

This commit is contained in:
Hai Shi 2020-05-28 06:10:27 +08:00 committed by GitHub
parent 7d80b35af1
commit e80697d687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 483 additions and 428 deletions

View file

@ -11,6 +11,7 @@ import unittest
import weakref
from test import support
from test.support import threading_helper
requires_fork = unittest.skipUnless(hasattr(os, 'fork'),
@ -37,7 +38,7 @@ class Bunch(object):
self.started = []
self.finished = []
self._can_exit = not wait_before_exit
self.wait_thread = support.wait_threads_exit()
self.wait_thread = threading_helper.wait_threads_exit()
self.wait_thread.__enter__()
def task():
@ -73,10 +74,10 @@ class Bunch(object):
class BaseTestCase(unittest.TestCase):
def setUp(self):
self._threads = support.threading_setup()
self._threads = threading_helper.threading_setup()
def tearDown(self):
support.threading_cleanup(*self._threads)
threading_helper.threading_cleanup(*self._threads)
support.reap_children()
def assertTimeout(self, actual, expected):
@ -239,7 +240,7 @@ class LockTests(BaseLockTests):
lock.acquire()
phase.append(None)
with support.wait_threads_exit():
with threading_helper.wait_threads_exit():
start_new_thread(f, ())
while len(phase) == 0:
_wait()