Skip to content

Commit

Permalink
Log error in updates_invoke_error variable, on all invokes.
Browse files Browse the repository at this point in the history
  • Loading branch information
eyMarv committed Jan 20, 2024
1 parent a82c14a commit 3ee60ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pyrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3ee60ac

Please sign in to comment.