Raise and handle send errors in order to immediately act upon

This commit is contained in:
Dan 2022-12-28 00:21:05 +01:00
parent 5ca422b314
commit 1daa05a35c
2 changed files with 6 additions and 1 deletions

View File

@ -101,6 +101,7 @@ class TCP:
await self.writer.drain()
except Exception as e:
log.warning("Send exception: %s %s", type(e).__name__, e)
raise OSError(e)
async def recv(self, length: int = 0):
data = b""

View File

@ -297,7 +297,11 @@ class Session:
self.auth_key_id
)
try:
await self.connection.send(payload)
except OSError as e:
self.results.pop(msg_id, None)
raise e
if wait_response:
try: