mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-13 04:56:35 +03:00
Turn socket.timeout error into the more general TimeoutError
This commit is contained in:
parent
494b82ea9d
commit
2a5d08b23d
|
@ -69,6 +69,8 @@ class TcpClient:
|
||||||
# The socket timeout is now the maximum total duration to send all data.
|
# The socket timeout is now the maximum total duration to send all data.
|
||||||
try:
|
try:
|
||||||
self._socket.sendall(data)
|
self._socket.sendall(data)
|
||||||
|
except socket.timeout as e:
|
||||||
|
raise TimeoutError() from e
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
self.close()
|
self.close()
|
||||||
raise
|
raise
|
||||||
|
@ -86,7 +88,11 @@ class TcpClient:
|
||||||
with BufferedWriter(BytesIO(), buffer_size=size) as buffer:
|
with BufferedWriter(BytesIO(), buffer_size=size) as buffer:
|
||||||
bytes_left = size
|
bytes_left = size
|
||||||
while bytes_left != 0:
|
while bytes_left != 0:
|
||||||
partial = self._socket.recv(bytes_left)
|
try:
|
||||||
|
partial = self._socket.recv(bytes_left)
|
||||||
|
except socket.timeout as e:
|
||||||
|
raise TimeoutError() from e
|
||||||
|
|
||||||
if len(partial) == 0:
|
if len(partial) == 0:
|
||||||
self.close()
|
self.close()
|
||||||
raise ConnectionResetError(
|
raise ConnectionResetError(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user