mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 02:29:28 +08:00
EventBus.reset cleared the class singleton (_instance/_initialized) but not the module-level _event_bus that get_event_bus caches. After a reset, get_event_bus kept returning the previous, stopped bus (_running=False, processor task cancelled), while a direct EventBus() built a fresh one — the two singleton paths diverged. Reset the module-level reference too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
17 lines
503 B
Python
17 lines
503 B
Python
"""EventBus singleton reset semantics."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from deeptutor.events.event_bus import EventBus, get_event_bus
|
|
|
|
|
|
def test_reset_clears_the_module_level_accessor() -> None:
|
|
# get_event_bus caches its own module-level singleton; reset() must clear it
|
|
# too, or the accessor keeps handing back a stopped bus after a reset.
|
|
first = get_event_bus()
|
|
try:
|
|
EventBus.reset()
|
|
assert get_event_bus() is not first
|
|
finally:
|
|
EventBus.reset()
|