From c24c39a2ae1609c21662af28b3c120927fc9e4b0 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 13 Sep 2023 03:54:28 +0200 Subject: [PATCH] gh-109357: Fix test_monitoring.test_gh108976() (GH-109358) The test now calls free_tool_id() so it can be run multiple times in the same process. For example, the following command no longer fails: python -m test test_monitoring -R 3:3 (cherry picked from commit 388d91cd474de80355f5a8f6a26e8962813a3128) Co-authored-by: Victor Stinner --- Lib/test/test_monitoring.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 2e4ec244ce6f17..d091572b0880d6 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -1721,6 +1721,7 @@ def make_foo_optimized_then_set_event(): def test_gh108976(self): sys.monitoring.use_tool_id(0, "test") + self.addCleanup(sys.monitoring.free_tool_id, 0) sys.monitoring.set_events(0, 0) sys.monitoring.register_callback(0, E.LINE, lambda *args: sys.monitoring.set_events(0, 0)) sys.monitoring.register_callback(0, E.INSTRUCTION, lambda *args: 0)