2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-09-04 08:15:08 +00:00

Add timeout on recv loop

This commit is contained in:
Dan
2018-06-17 18:33:23 +02:00
parent 39b66b51d6
commit 2b0746a140

View File

@@ -334,7 +334,10 @@ class Session:
log.info("RecvTask started")
while True:
packet = await self.connection.recv()
try:
packet = await asyncio.wait_for(self.connection.recv(), self.connection.TIMEOUT)
except asyncio.TimeoutError:
packet = None
if packet is None or len(packet) == 4:
if packet: