Skip to content

Commit 1daa05a

Browse files
committed
Raise and handle send errors in order to immediately act upon
1 parent 5ca422b commit 1daa05a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pyrogram/connection/transport/tcp/tcp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async def send(self, data: bytes):
101101
await self.writer.drain()
102102
except Exception as e:
103103
log.warning("Send exception: %s %s", type(e).__name__, e)
104+
raise OSError(e)
104105

105106
async def recv(self, length: int = 0):
106107
data = b""

pyrogram/session/session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ async def send(self, data: TLObject, wait_response: bool = True, timeout: float
297297
self.auth_key_id
298298
)
299299

300-
await self.connection.send(payload)
300+
try:
301+
await self.connection.send(payload)
302+
except OSError as e:
303+
self.results.pop(msg_id, None)
304+
raise e
301305

302306
if wait_response:
303307
try:

0 commit comments

Comments
 (0)