mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 13:14:31 +03:00
Handle dispatcher CancelledError during disconnect
This commit is contained in:
parent
c49f0827b1
commit
854d3745b3
|
@ -210,6 +210,8 @@ async def disconnect(self: Client) -> None:
|
|||
self._dispatcher.cancel()
|
||||
try:
|
||||
await self._dispatcher
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"unhandled exception when cancelling dispatcher; this is a bug"
|
||||
|
|
|
@ -130,7 +130,7 @@ async def dispatcher(client: Client) -> None:
|
|||
try:
|
||||
await dispatch_next(client)
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
raise
|
||||
except Exception as e:
|
||||
if isinstance(e, RuntimeError) and loop.is_closed():
|
||||
# User probably forgot to call disconnect.
|
||||
|
|
Loading…
Reference in New Issue
Block a user