Skip to content

Commit

Permalink
fix: service class trying to get event loop on init (#61)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nourselim0 committed Apr 9, 2024
1 parent 15a4fea commit d0a2a59
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mode/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,16 @@ def __init__(
super().__init__(loop=self._loop)

def _new_started_event(self) -> Event:
return Event(loop=self.loop)
return Event(loop=self._loop)

def _new_stopped_event(self) -> Event:
return Event(loop=self.loop)
return Event(loop=self._loop)

def _new_shutdown_event(self) -> Event:
return Event(loop=self.loop)
return Event(loop=self._loop)

def _new_crashed_event(self) -> Event:
return Event(loop=self.loop)
return Event(loop=self._loop)

async def transition_with(
self, flag: str, fut: Awaitable, *args: Any, **kwargs: Any
Expand Down

0 comments on commit d0a2a59

Please sign in to comment.