Skip to content

Commit

Permalink
- improved logging
Browse files Browse the repository at this point in the history
- resolved python 3.11 issue (#51)
  • Loading branch information
simbaja committed Apr 23, 2023
1 parent 633c8aa commit 94b7764
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gehomesdk/clients/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async def CancellableAsyncIterator(async_iterator: AsyncIterator, cancellation_e
result_iter = async_iterator.__aiter__()
while not cancellation_event.is_set():
done, pending = await asyncio.wait(
[cancellation_task, result_iter.__anext__()],
[cancellation_task, asyncio.create_task(result_iter.__anext__())],
return_when=asyncio.FIRST_COMPLETED
)
for done_task in done:
Expand Down
5 changes: 4 additions & 1 deletion gehomesdk/clients/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ def event_handlers(self) -> Dict[str, List[Callable]]:
return self._event_handlers

async def async_event(self, event: str, *args, **kwargs):
_LOGGER.debug(f"received event: {event}, processing callbacks...")
"""Trigger event callbacks sequentially"""
for cb in self.event_handlers[event]:
_LOGGER.debug(f"processing callback: {cb}")
asyncio.ensure_future(cb(*args, **kwargs), loop=self.loop)

def add_event_handler(self, event: str, callback: Callable, disposable: bool = False):
Expand Down Expand Up @@ -136,7 +138,8 @@ async def async_run_client(self):
if not self._has_successful_connect:
_LOGGER.warn(f'Unhandled exception on first connect attempt: {err}, disconnecting')
break
_LOGGER.info(f'Unhandled exception while running client: {err}, ignoring and restarting')
_LOGGER.exception(err)
_LOGGER.info(f'Unhandled exception while running client, ignoring and restarting')
finally:
if not self._disconnect_requested.is_set():
await self._set_state(GeClientState.DROPPED)
Expand Down

0 comments on commit 94b7764

Please sign in to comment.