From e8af64eafc943906368293bb51933fcf26bd2dd3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 5 Nov 2026 16:46:38 +0000 Subject: [PATCH] tests: Comment on self.addCleanup ordering --- tests/metrics/test_thread_cpu.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/metrics/test_thread_cpu.py b/tests/metrics/test_thread_cpu.py index 1ac3d50173..a35f8550a5 100644 --- a/tests/metrics/test_thread_cpu.py +++ b/tests/metrics/test_thread_cpu.py @@ -91,8 +91,12 @@ class ThreadCPUMetricsTestCase(unittest.TestCase): # 3.14 onwards. thread = threading.Thread(target=run_on_thread, name="a) b) (c") thread.start() + + # Cleanup functions are run in reverse order, so first we set the + # release event (to wake the thread up), and then we wait for it exit. self.addCleanup(thread.join) self.addCleanup(release.set) + metrics.register_thread("test-thread", thread) # Wait for the separate thread to burn CPU before continuing.