Skip to content

Commit 44944b6

Browse files
authored
bpo-30387: Fix warning in test_threading (#1634) (#1636)
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. (cherry picked from commit f8d05b3)
1 parent 69f3a5a commit 44944b6

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
@@ -470,13 +470,15 @@ def test_is_alive_after_fork(self):
470470
for i in range(20):
471471
t = threading.Thread(target=lambda: None)
472472
t.start()
473-
self.addCleanup(t.join)
474473
pid = os.fork()
475474
if pid == 0:
476-
os._exit(1 if t.is_alive() else 0)
475+
os._exit(11 if t.is_alive() else 10)
477476
else:
477+
t.join()
478+
478479
pid, status = os.waitpid(pid, 0)
479-
self.assertEqual(0, status)
480+
self.assertTrue(os.WIFEXITED(status))
481+
self.assertEqual(10, os.WEXITSTATUS(status))
480482

481483
def test_main_thread(self):
482484
main = threading.main_thread()

0 commit comments

Comments
 (0)