Skip to content

Commit

Permalink
Cleanup async_events renewal logging and exceptions (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlawren authored and pwt committed May 19, 2021
1 parent 1333e36 commit 404f4ac
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions soco/events_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,22 +416,16 @@ async def renew(
try:
return await super().renew(requested_timeout, is_autorenew)
except Exception as exc: # pylint: disable=broad-except
msg = (
"An Exception occurred. Subscription to"
+ " {}, sid: {} has been cancelled".format(
self.service.base_url + self.service.event_subscription_url,
self.sid,
)
)
log.exception(msg)
self._cancel_subscription(msg)
if self.auto_renew_fail is not None:
if hasattr(self.auto_renew_fail, "__call__"):
# pylint: disable=not-callable
self.auto_renew_fail(exc)
self._cancel_subscription(exc)
if self.auto_renew_fail is not None and hasattr(
self.auto_renew_fail, "__call__"
):
# pylint: disable=not-callable
self.auto_renew_fail(exc)
else:
self._log_exception(exc)
if strict:
raise
self._log_exception(exc)
return self

async def unsubscribe(
Expand Down Expand Up @@ -470,7 +464,7 @@ def _auto_renew_start(self, interval):
)

def _auto_renew_run(self, interval):
asyncio.ensure_future(self.renew(is_autorenew=True))
asyncio.ensure_future(self.renew(is_autorenew=True, strict=False))
self._auto_renew_start(interval)

def _auto_renew_cancel(self):
Expand Down

0 comments on commit 404f4ac

Please sign in to comment.