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

@ -7,6 +7,7 @@ import time
import unittest
import weakref
from test import support
from test.support import threading_helper
py_queue = support.import_fresh_module('queue', blocked=['_queue'])
c_queue = support.import_fresh_module('queue', fresh=['_queue'])
@ -63,7 +64,7 @@ class BlockingTestMixin:
block_func)
return self.result
finally:
support.join_thread(thread) # make sure the thread terminates
threading_helper.join_thread(thread) # 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,
@ -79,7 +80,7 @@ class BlockingTestMixin:
self.fail("expected exception of kind %r" %
expected_exception_class)
finally:
support.join_thread(thread) # make sure the thread terminates
threading_helper.join_thread(thread) # make sure the thread terminates
if not thread.startedEvent.is_set():
self.fail("trigger thread ended but event never set")
@ -484,7 +485,7 @@ class BaseSimpleQueueTest:
args=(q, results, sentinel))
for i in range(n_consumers)]
with support.start_threads(feeders + consumers):
with threading_helper.start_threads(feeders + consumers):
pass
self.assertFalse(exceptions)