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)