Skip to content

Commit f8d05b3

Browse files
authored
bpo-30387: Fix warning in test_threading (#1634)
test_is_alive_after_fork() now joins directly the thread to avoid the following warning added by bpo-30357: Warning -- threading_cleanup() failed to cleanup 0 threads after 2 sec (count: 0, dangling: 21) Use also a different exit code to catch generic exit code 1.
1 parent 6f75bc0 commit f8d05b3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_threading.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,15 @@ def test_is_alive_after_fork(self):
473473
for i in range(20):
474474
t = threading.Thread(target=lambda: None)
475475
t.start()
476-
self.addCleanup(t.join)
477476
pid = os.fork()
478477
if pid == 0:
479-
os._exit(1 if t.is_alive() else 0)
478+
os._exit(11 if t.is_alive() else 10)
480479
else:
480+
t.join()
481+
481482
pid, status = os.waitpid(pid, 0)
482-
self.assertEqual(0, status)
483+
self.assertTrue(os.WIFEXITED(status))
484+
self.assertEqual(10, os.WEXITSTATUS(status))
483485

484486
def test_main_thread(self):
485487
main = threading.main_thread()

0 commit comments

Comments
 (0)