mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 21:24:35 +03:00
Handle RuntimeError on helpers._cancel and improve logging
This commit is contained in:
parent
94ff5a8641
commit
1bd02d64c5
|
@ -106,8 +106,20 @@ async def _cancel(log, **tasks):
|
||||||
await task
|
await task
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
|
except RuntimeError:
|
||||||
|
# Probably: RuntimeError: await wasn't used with future
|
||||||
|
#
|
||||||
|
# Happens with _asyncio.Task instances (in "Task cancelling" state)
|
||||||
|
# trying to SIGINT the program right during initial connection, on
|
||||||
|
# _recv_loop coroutine (but we're creating its task explicitly with
|
||||||
|
# a loop, so how can it bug out like this?).
|
||||||
|
#
|
||||||
|
# Since we're aware of this error there's no point in logging it.
|
||||||
|
# *May* be https://bugs.python.org/issue37172
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('Unhandled exception from %s after cancel', name)
|
log.exception('Unhandled exception from %s after cancelling '
|
||||||
|
'%s (%s)', name, type(task), task)
|
||||||
|
|
||||||
|
|
||||||
def _sync_enter(self):
|
def _sync_enter(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user