diff --git a/pyrogram/client.py b/pyrogram/client.py index eaec620a3..e714c2962 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -338,7 +338,7 @@ def __init__( # after some idle time has been detected. self.updates_watchdog_task = None self.updates_watchdog_event = asyncio.Event() - self.updates_watchdog_error = None + self.updates_invoke_error = None self.last_update_time = datetime.now() self.listeners = {listener_type: [] for listener_type in pyrogram.enums.ListenerTypes} self.loop = asyncio.get_event_loop() @@ -370,11 +370,8 @@ async def updates_watchdog(self): else: break - try: - if datetime.now() - self.last_update_time > timedelta(seconds=self.UPDATES_WATCHDOG_INTERVAL): - await self.invoke(raw.functions.updates.GetState()) - except Exception as ee: - self.updates_watchdog_error = ee + if datetime.now() - self.last_update_time > timedelta(seconds=self.UPDATES_WATCHDOG_INTERVAL): + await self.invoke(raw.functions.updates.GetState()) async def authorize(self) -> User: if self.bot_token: diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 0423dba1c..8ab42a0d7 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -423,3 +423,5 @@ async def invoke( await asyncio.sleep(0.5) return await self.invoke(query, retries - 1, timeout) + except Exception as ex: + self.client.updates_invoke_error = ex