https://github.com/python/cpython/commit/8b26b23a9674a02563f28e4cfbef3d3e39876bfe
commit: 8b26b23a9674a02563f28e4cfbef3d3e39876bfe
branch: main
author: Petr Viktorin <encu...@gmail.com>
committer: encukou <encu...@gmail.com>
date: 2025-04-30T15:14:24+02:00
summary:

gh-87135: test_threading: Wait on thread, not an Event it sets (GH-133198)

When the event is set the thread might not be done yet.

This is a fix-up for commit 4ebbfcf30e0e2d87ff6036d4d1de0f6f0ef7c46a

files:
M Lib/test/test_threading.py

diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index b768886362654f..814c00ca0fd7b6 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1219,18 +1219,18 @@ def 
test_join_finished_daemon_thread_in_finalization(self):
             import threading
             done = threading.Event()
 
-            def loop():
+            def set_event():
                 done.set()
 
-
             class Cycle:
                 def __init__(self):
                     self.self_ref = self
-                    self.thr = threading.Thread(target=loop, daemon=True)
+                    self.thr = threading.Thread(target=set_event, daemon=True)
                     self.thr.start()
-                    done.wait()
+                    self.thr.join()
 
                 def __del__(self):
+                    assert done.is_set()
                     assert not self.thr.is_alive()
                     self.thr.join()
                     assert not self.thr.is_alive()

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to