mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-09 08:00:53 +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()
|
self._dispatcher.cancel()
|
||||||
try:
|
try:
|
||||||
await self._dispatcher
|
await self._dispatcher
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
self._logger.exception(
|
self._logger.exception(
|
||||||
"unhandled exception when cancelling dispatcher; this is a bug"
|
"unhandled exception when cancelling dispatcher; this is a bug"
|
||||||
|
|
|
@ -130,7 +130,7 @@ async def dispatcher(client: Client) -> None:
|
||||||
try:
|
try:
|
||||||
await dispatch_next(client)
|
await dispatch_next(client)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
return
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, RuntimeError) and loop.is_closed():
|
if isinstance(e, RuntimeError) and loop.is_closed():
|
||||||
# User probably forgot to call disconnect.
|
# User probably forgot to call disconnect.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user