8000 handle the TimedOut exception · guillemap/python-telegram-bot@ecc5642 · GitHub
[go: up one dir, main page]

Skip to content

Commit ecc5642

Browse files
authored
handle the TimedOut exception
1 parent 83af875 commit ecc5642

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

telegram/ext/_updater.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,22 @@ async def _get_updates_cleanup() -> None:
401401
_LOGGER.debug(
402402
"Calling `get_updates` one more time to mark all fetched updates as read."
403403
)
404-
await self.bot.get_updates(
405-
offset=self._last_update_id,
406-
# We don't want to do long polling here!
407-
timeout=2,
408-
read_timeout=read_timeout,
409-
connect_timeout=connect_timeout,
410-
write_timeout=write_timeout,
411-
pool_timeout=pool_timeout,
412-
allowed_updates=allowed_updates,
413-
)
404+
try:
405+
await self.bot.get_updates(
406+
offset=self._last_update_id,
407+
# We don't want to do long polling here!
408+
timeout=0,
409+
read_timeout=read_timeout,
410+
connect_timeout=connect_timeout,
411+
write_timeout=write_timeout,
412+
pool_timeout=pool_timeout,
413+
allowed_updates=allowed_updates,
414+
)
415+
except TimedOut:
416+
_LOGGER.debug(
417+
"`get_updates` timed out while marking updates as read. The last fetched "
418+
"updates may be fetched again on the next polling start."
419+
)
414420

415421
self.__polling_cleanup_cb = _get_updates_cleanup
416422

0 commit comments

Comments
 (0)
0