File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ async def __aexit__(
129129 if self ._active_ref_count > 1 :
130130 # Emit persist state event to ensure the latest state is saved before closing the context.
131131 await self ._emit_persist_state_event ()
132+ await self .wait_for_all_listeners_to_complete (timeout = self ._close_timeout )
132133 self ._active_ref_count -= 1
133134 return
134135
Original file line number Diff line number Diff line change @@ -75,7 +75,10 @@ async def __aenter__(self) -> LocalEventManager:
7575 It starts emitting system info events at regular intervals.
7676 """
7777 await super ().__aenter__ ()
78- self ._emit_system_info_event_rec_task .start ()
78+
79+ if self ._active_ref_count == 1 :
80+ self ._emit_system_info_event_rec_task .start ()
81+
7982 return self
8083
8184 async def __aexit__ (
@@ -88,7 +91,9 @@ async def __aexit__(
8891
8992 It stops emitting system info events and closes the event manager.
9093 """
91- await self ._emit_system_info_event_rec_task .stop ()
94+ if self ._active_ref_count == 1 :
95+ await self ._emit_system_info_event_rec_task .stop ()
96+
9297 await super ().__aexit__ (exc_type , exc_value , exc_traceback )
9398
9499 async def _emit_system_info_event (self ) -> None :
You can’t perform that action at this time.
0 commit comments