]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-87135: test_threading: Wait on thread, not an Event it sets (GH-133198)
authorPetr Viktorin <encukou@gmail.com>
Wed, 30 Apr 2025 13:14:24 +0000 (15:14 +0200)
committerGitHub <noreply@github.com>
Wed, 30 Apr 2025 13:14:24 +0000 (15:14 +0200)
When the event is set the thread might not be done yet.

This is a fix-up for commit 4ebbfcf30e0e2d87ff6036d4d1de0f6f0ef7c46a

Lib/test/test_threading.py

index b768886362654f87d6b04cf1318d33e3c24d5db0..814c00ca0fd7b62ffd58450dd3493be3e587e3fc 100644 (file)
@@ -1219,18 +1219,18 @@ class ThreadTests(BaseTestCase):
             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()