mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +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)
|
view = memoryview(data)
|
||||||
total_sent, total = 0, len(data)
|
total_sent, total = 0, len(data)
|
||||||
while total_sent < total:
|
while total_sent < total:
|
||||||
sent = self._socket.send(view[total_sent:])
|
try:
|
||||||
if sent == 0:
|
sent = self._socket.send(view[total_sent:])
|
||||||
raise ConnectionResetError(
|
if sent == 0:
|
||||||
'The server has closed the connection.')
|
raise ConnectionResetError(
|
||||||
total_sent += sent
|
'The server has closed the connection.')
|
||||||
|
total_sent += sent
|
||||||
|
|
||||||
|
except BlockingIOError:
|
||||||
|
time.sleep(self.delay)
|
||||||
|
|
||||||
def read(self, size, timeout=timedelta(seconds=5)):
|
def read(self, size, timeout=timedelta(seconds=5)):
|
||||||
"""Reads (receives) a whole block of 'size bytes
|
"""Reads (receives) a whole block of 'size bytes
|
||||||
|
|
Loading…
Reference in New Issue
Block a user