mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Fix asyncio.CancelledError was being swallowed by inner except
Closes #4104.
This commit is contained in:
parent
980f8b32fc
commit
6a7a981b7a
|
@ -256,6 +256,8 @@ class Connection(abc.ABC):
|
||||||
if not self._connected:
|
if not self._connected:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self._connected = False
|
||||||
|
|
||||||
await helpers._cancel(
|
await helpers._cancel(
|
||||||
self._log,
|
self._log,
|
||||||
send_task=self._send_task,
|
send_task=self._send_task,
|
||||||
|
@ -279,8 +281,6 @@ class Connection(abc.ABC):
|
||||||
# * ConnectionResetError
|
# * ConnectionResetError
|
||||||
self._log.info('%s during disconnect: %s', type(e), e)
|
self._log.info('%s during disconnect: %s', type(e), e)
|
||||||
|
|
||||||
self._connected = False
|
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
"""
|
"""
|
||||||
Sends a packet of data through this connection mode.
|
Sends a packet of data through this connection mode.
|
||||||
|
@ -333,6 +333,8 @@ class Connection(abc.ABC):
|
||||||
while self._connected:
|
while self._connected:
|
||||||
try:
|
try:
|
||||||
data = await self._recv()
|
data = await self._recv()
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
break
|
||||||
except (IOError, asyncio.IncompleteReadError) as e:
|
except (IOError, asyncio.IncompleteReadError) as e:
|
||||||
self._log.warning('Server closed the connection: %s', e)
|
self._log.warning('Server closed the connection: %s', e)
|
||||||
await self._recv_queue.put((None, e))
|
await self._recv_queue.put((None, e))
|
||||||
|
@ -349,8 +351,6 @@ class Connection(abc.ABC):
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
else:
|
else:
|
||||||
await self._recv_queue.put((data, None))
|
await self._recv_queue.put((data, None))
|
||||||
except asyncio.CancelledError:
|
|
||||||
pass
|
|
||||||
finally:
|
finally:
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user