From 2132a74321362d215e9a8e1d46d1223899efb381 Mon Sep 17 00:00:00 2001 From: Twirre Meulenbelt <43213592+TwirreM@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:34:51 +0200 Subject: [PATCH] fix: allow access to state's `exit_event` while exiting When exiting, the state's `is_initialized` flag is unset. Noticeable on Windows, when a thread tried to access the state's `exit_event` property to check whether it had been set, it would complain that the state was no longer initialized. Now, even when no longer initialized, if the `exit_event` is set, it will not raise an error when accessing this attribute. ref: N25B-119 --- state.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/state.py b/state.py index 8d33898..d80a954 100644 --- a/state.py +++ b/state.py @@ -37,7 +37,12 @@ class State(object): if name in ("initialize", "deinitialize", "is_initialized", "__dict__", "__class__"): return object.__getattribute__(self, name) - if not self.is_initialized: + if not object.__getattribute__(self, "is_initialized"): + # Special case for the exit_event: if the event is set, return it without an error + if name == "exit_event": + exit_event = object.__getattribute__(self, "exit_event") + if exit_event and exit_event.is_set(): return exit_event + raise RuntimeError("State must be initialized before accessing '%s'" % name) return object.__getattribute__(self, name)