mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Raise an exception if recv() returned 0 bytes
See for details: https://docs.python.org/3/howto/sockets.html "When a recv returns 0 bytes, it means the other side has closed (or is in the process of closing) the connection. You will not receive any more data on this connection. Ever."
This commit is contained in:
parent
3c3946e6f1
commit
bbd3eb7c28
|
@ -82,6 +82,9 @@ class TcpClient:
|
|||
# This is why we need to keep checking to make sure that we receive it all
|
||||
left_count = buffer_size - writer.written_count
|
||||
partial = self.socket.recv(left_count)
|
||||
if len(partial) == 0:
|
||||
raise ConnectionResetError(
|
||||
'The server has closed the connection (recv() returned 0 bytes).')
|
||||
writer.write(partial)
|
||||
|
||||
except BlockingIOError as error:
|
||||
|
|
Loading…
Reference in New Issue
Block a user