Telethon
Telethon copied to clipboard
CancelledError should not be 'except'ed
Traceback
Fatal error handling updates (this is a bug in Telethon, please report it)
Traceback (most recent call last):
File "/project/resources/venv/lib/python3.7/site-packages/telethon/_client/updates.py", line 119, in _update_loop
deadline - asyncio.get_running_loop().time()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 435, in wait_for
await waiter
concurrent.futures._base.CancelledError
Hi there, I'm trying out v2. Please note that CancelledError is a subclass of Exception (and not BaseException) in Python < 3.8. If you want to support these versions, you can reraise CancelledError before cathing Exception like so:
try:
await smth()
except asyncio.CancelledError:
raise
except Exception:
...
It looks a bit ugly, but there is no decent workaround.
Ah, good point, yeah, cancellation is an expected error so this except
:
https://github.com/LonamiWebs/Telethon/blob/7778e54467d1ed5079828aad2069f4571d39e107/telethon/_client/telegrambaseclient.py#L365-L368
Should be moved to be just above:
https://github.com/LonamiWebs/Telethon/blob/7778e54467d1ed5079828aad2069f4571d39e107/telethon/_client/updates.py#L129-L130
Closing since this should be fixed in the current v1 branch. v2 is not ready for public use yet.