From f88bdb70865bcd2ec0de2ba2dad21d573dedd2b1 Mon Sep 17 00:00:00 2001 From: Royalaid <2439803+royalaid@users.noreply.github.com> Date: Fri, 28 Aug 2026 19:57:24 -0700 Subject: [PATCH] test(interrupt): clear publisher thread state --- tests/tools/test_interrupt.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/tools/test_interrupt.py b/tests/tools/test_interrupt.py index 3cec9c6d12..5b7c00c9a3 100644 --- a/tests/tools/test_interrupt.py +++ b/tests/tools/test_interrupt.py @@ -75,14 +75,21 @@ class TestInterruptModule: assert callbacks == [] def test_run_if_not_interrupted_orders_callback_before_concurrent_interrupt(self): - from tools.interrupt import run_if_not_interrupted, set_interrupt + from tools.interrupt import ( + _interrupted_threads, + _lock, + run_if_not_interrupted, + set_interrupt, + ) setter_started = threading.Event() interrupt_published = threading.Event() callback_observations = [] setters = [] + setter_tids = [] def publish_interrupt(): + setter_tids.append(threading.get_ident()) setter_started.set() set_interrupt(True) interrupt_published.set() @@ -96,14 +103,20 @@ class TestInterruptModule: assert run_if_not_interrupted(callback) is True setter = setters[0] - setter.join(5) try: + setter.join(5) assert not setter.is_alive() assert callback_observations == [False] assert interrupt_published.is_set() finally: + for setter_tid in setter_tids: + set_interrupt(False, setter_tid) set_interrupt(False) + assert setter_tids + with _lock: + assert setter_tids[0] not in _interrupted_threads + # --------------------------------------------------------------------------- # Unit tests: pre-tool interrupt check