Skip to content

Commit 7f45493

Browse files
author
Hassan Selim
authored
fix: service class trying to get event loop on init (#61) (#62)
The `_new_*_event` methods on the `Service` class were calling the `loop` property instead of using the `_loop` attribute, the property tried to fetch the current thread's event loop which caused some odd issues, this fix delays that until the event loop is actually needed (lazy loading).
1 parent 15a4fea commit 7f45493

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mode/services.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,16 +596,16 @@ def __init__(
596596
super().__init__(loop=self._loop)
597597

598598
def _new_started_event(self) -> Event:
599-
return Event(loop=self.loop)
599+
return Event(loop=self._loop)
600600

601601
def _new_stopped_event(self) -> Event:
602-
return Event(loop=self.loop)
602+
return Event(loop=self._loop)
603603

604604
def _new_shutdown_event(self) -> Event:
605-
return Event(loop=self.loop)
605+
return Event(loop=self._loop)
606606

607607
def _new_crashed_event(self) -> Event:
608-
return Event(loop=self.loop)
608+
return Event(loop=self._loop)
609609

610610
async def transition_with(
611611
self, flag: str, fut: Awaitable, *args: Any, **kwargs: Any

0 commit comments

Comments
 (0)