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

@ -5,6 +5,7 @@ import signal
import os
import sys
from test import support
from test.support import threading_helper
import _thread as thread
import time
@ -39,7 +40,7 @@ def send_signals():
class ThreadSignals(unittest.TestCase):
def test_signals(self):
with support.wait_threads_exit():
with threading_helper.wait_threads_exit():
# Test signal handling semantics of threads.
# We spawn a thread, have the thread send two signals, and
# wait for it to finish. Check that we got both signals
@ -129,7 +130,7 @@ class ThreadSignals(unittest.TestCase):
def other_thread():
rlock.acquire()
with support.wait_threads_exit():
with threading_helper.wait_threads_exit():
thread.start_new_thread(other_thread, ())
# Wait until we can't acquire it without blocking...
while rlock.acquire(blocking=False):
@ -165,7 +166,7 @@ class ThreadSignals(unittest.TestCase):
time.sleep(0.5)
lock.release()
with support.wait_threads_exit():
with threading_helper.wait_threads_exit():
thread.start_new_thread(other_thread, ())
# Wait until we can't acquire it without blocking...
while lock.acquire(blocking=False):
@ -212,7 +213,7 @@ class ThreadSignals(unittest.TestCase):
os.kill(process_pid, signal.SIGUSR1)
done.release()
with support.wait_threads_exit():
with threading_helper.wait_threads_exit():
# Send the signals from the non-main thread, since the main thread
# is the only one that can process signals.
thread.start_new_thread(send_signals, ())