mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
[3.6] bpo-31234: Join threads in tests (#3589)
* bpo-31234: Join threads in tests (#3572) Call thread.join() on threads to prevent the "dangling threads" warning. (cherry picked from commit18e95b4176
) * bpo-31234: Join threads in test_hashlib (#3573) * bpo-31234: Join threads in test_hashlib Use thread.join() to wait until the parallel hash tasks complete rather than using events. Calling thread.join() prevent "dangling thread" warnings. * test_hashlib: minor PEP 8 coding style fixes (cherry picked from commit8dcf22f442
) * bpo-31234: Join threads in test_threading (#3579) Call thread.join() to prevent the "dangling thread" warning. (cherry picked from commitb8c7be2c52
) * bpo-31234: Join threads in test_queue (#3586) Call thread.join() to prevent the "dangling thread" warning. (cherry picked from commit167cbde50a
) * bpo-31234: Join timers in test_threading (#3598) Call the .join() method of threading.Timer timers to prevent the "threading_cleanup() failed to cleanup 1 threads" warning. (cherry picked from commitda3e5cf961
)
This commit is contained in:
parent
4d72945a28
commit
2c1c2ca254
7 changed files with 58 additions and 36 deletions
|
@ -575,6 +575,7 @@ class ThreadTests(BaseTestCase):
|
|||
self.assertFalse(t.is_alive())
|
||||
# And verify the thread disposed of _tstate_lock.
|
||||
self.assertIsNone(t._tstate_lock)
|
||||
t.join()
|
||||
|
||||
def test_repr_stopped(self):
|
||||
# Verify that "stopped" shows up in repr(Thread) appropriately.
|
||||
|
@ -601,6 +602,7 @@ class ThreadTests(BaseTestCase):
|
|||
break
|
||||
time.sleep(0.01)
|
||||
self.assertIn(LOOKING_FOR, repr(t)) # we waited at least 5 seconds
|
||||
t.join()
|
||||
|
||||
def test_BoundedSemaphore_limit(self):
|
||||
# BoundedSemaphore should raise ValueError if released too often.
|
||||
|
@ -915,6 +917,7 @@ class ThreadingExceptionTests(BaseTestCase):
|
|||
thread = threading.Thread()
|
||||
thread.start()
|
||||
self.assertRaises(RuntimeError, thread.start)
|
||||
thread.join()
|
||||
|
||||
def test_joining_current_thread(self):
|
||||
current_thread = threading.current_thread()
|
||||
|
@ -928,6 +931,7 @@ class ThreadingExceptionTests(BaseTestCase):
|
|||
thread = threading.Thread()
|
||||
thread.start()
|
||||
self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
|
||||
thread.join()
|
||||
|
||||
def test_releasing_unacquired_lock(self):
|
||||
lock = threading.Lock()
|
||||
|
@ -1090,6 +1094,8 @@ class TimerTests(BaseTestCase):
|
|||
self.callback_event.wait()
|
||||
self.assertEqual(len(self.callback_args), 2)
|
||||
self.assertEqual(self.callback_args, [((), {}), ((), {})])
|
||||
timer1.join()
|
||||
timer2.join()
|
||||
|
||||
def _callback_spy(self, *args, **kwargs):
|
||||
self.callback_args.append((args[:], kwargs.copy()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue