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.
This commit is contained in:
Lonami Exo 2018-06-17 20:25:22 +02:00
parent d5b349e031
commit e36aff51dd

View File

@ -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