mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Handle dispatcher CancelledError during disconnect
This commit is contained in:
@@ -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.
|
||||||
|
Reference in New Issue
Block a user