mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Also except BlockingIOError on TcpClient.send()
This commit is contained in:
parent
769692959f
commit
d8afb7e548
|
@ -53,11 +53,15 @@ class TcpClient:
|
|||
view = memoryview(data)
|
||||
total_sent, total = 0, len(data)
|
||||
while total_sent < total:
|
||||
sent = self._socket.send(view[total_sent:])
|
||||
if sent == 0:
|
||||
raise ConnectionResetError(
|
||||
'The server has closed the connection.')
|
||||
total_sent += sent
|
||||
try:
|
||||
sent = self._socket.send(view[total_sent:])
|
||||
if sent == 0:
|
||||
raise ConnectionResetError(
|
||||
'The server has closed the connection.')
|
||||
total_sent += sent
|
||||
|
||||
except BlockingIOError:
|
||||
time.sleep(self.delay)
|
||||
|
||||
def read(self, size, timeout=timedelta(seconds=5)):
|
||||
"""Reads (receives) a whole block of 'size bytes
|
||||
|
|
Loading…
Reference in New Issue
Block a user