From e36aff51ddc64f0c93f6d1499409fc237912ad60 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 17 Jun 2018 20:25:22 +0200 Subject: [PATCH] Raise ConnectionError when sending without connection Otherwise the program could potentially block on await client(...) since this has no timeout (unless asyncio.wait_for() was used) and would give no further hint that the program was halted there. --- telethon/network/mtprotosender.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telethon/network/mtprotosender.py b/telethon/network/mtprotosender.py index f27ee5ef..e9908257 100644 --- a/telethon/network/mtprotosender.py +++ b/telethon/network/mtprotosender.py @@ -188,6 +188,9 @@ class MTProtoSender: Since the receiving part is "built in" the future, it's impossible to await receive a result that was never sent. """ + if not self._user_connected: + raise ConnectionError('Cannot send requests while disconnected') + if utils.is_list_like(request): result = [] after = None