From f0c1c666026a593119291eb8304b3be9e89f8865 Mon Sep 17 00:00:00 2001 From: MengAiDev Date: Mon, 21 Jul 2025 13:20:29 +0800 Subject: [PATCH 1/4] Commit message: Improve test cleanup and thread handling in monitoring tests - Replace manual thread alive checks with `join()` for reliability and efficiency - Disable monitoring events after test to prevent resource leaks - Fix race conditions by ensuring threads terminate before test completion --- Lib/test/test_free_threading/test_monitoring.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_free_threading/test_monitoring.py b/Lib/test/test_free_threading/test_monitoring.py index c3d0a2bcea5c17..cb15ca2b668e19 100644 --- a/Lib/test/test_free_threading/test_monitoring.py +++ b/Lib/test/test_free_threading/test_monitoring.py @@ -62,17 +62,9 @@ def test_instrumentation(self): self.after_threads() - while True: - any_alive = False - for t in threads: - if t.is_alive(): - any_alive = True - break - - if not any_alive: - break - - self.during_threads() + # Fix:use join() instead of is_alive() + for t in threads: + t.join() self.after_test() @@ -130,6 +122,8 @@ def callback(self, *args): self.called = True def after_test(self): + # 修复:确保测试结束后监控被禁用 + monitoring.set_events(self.tool_id, 0) self.assertTrue(self.called) def during_threads(self): From 945df52826f14482d7cf6dc8e35a2f35b90b2ef5 Mon Sep 17 00:00:00 2001 From: MengAiDev Date: Mon, 21 Jul 2025 13:34:30 +0800 Subject: [PATCH 2/4] add news --- Misc/NEWS.d/next/Tests.gh-136692.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests.gh-136692.rst diff --git a/Misc/NEWS.d/next/Tests.gh-136692.rst b/Misc/NEWS.d/next/Tests.gh-136692.rst new file mode 100644 index 00000000000000..3e2e4f6017a42c --- /dev/null +++ b/Misc/NEWS.d/next/Tests.gh-136692.rst @@ -0,0 +1 @@ +- Improve test cleanup and thread handling in monitoring , Patch by MengAiDev. \ No newline at end of file From 0c0f7c666c0b2805095c6b863f1d96db00574ead Mon Sep 17 00:00:00 2001 From: MengAiDev Date: Mon, 21 Jul 2025 13:36:32 +0800 Subject: [PATCH 3/4] fix news --- Misc/NEWS.d/next/{Tests.gh-136692.rst => Tests/gh-136692.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Tests.gh-136692.rst => Tests/gh-136692.rst} (100%) diff --git a/Misc/NEWS.d/next/Tests.gh-136692.rst b/Misc/NEWS.d/next/Tests/gh-136692.rst similarity index 100% rename from Misc/NEWS.d/next/Tests.gh-136692.rst rename to Misc/NEWS.d/next/Tests/gh-136692.rst From 5b0f8a8b58e22b77d27a769861603b8633eaa8ca Mon Sep 17 00:00:00 2001 From: MengAiDev Date: Mon, 21 Jul 2025 13:42:13 +0800 Subject: [PATCH 4/4] remove news --- Misc/NEWS.d/next/Tests/gh-136692.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/gh-136692.rst diff --git a/Misc/NEWS.d/next/Tests/gh-136692.rst b/Misc/NEWS.d/next/Tests/gh-136692.rst deleted file mode 100644 index 3e2e4f6017a42c..00000000000000 --- a/Misc/NEWS.d/next/Tests/gh-136692.rst +++ /dev/null @@ -1 +0,0 @@ -- Improve test cleanup and thread handling in monitoring , Patch by MengAiDev. \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy