mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 16:24:15 +03:00
TcpClient: Catch ConnectionError instead of its particular cases
That can be more reliable, especially in the case of using PySocks.
This commit is contained in:
parent
992017ddf8
commit
4a2a64ce2f
|
@ -113,7 +113,7 @@ class TcpClient:
|
||||||
self._socket.sendall(data)
|
self._socket.sendall(data)
|
||||||
except socket.timeout as e:
|
except socket.timeout as e:
|
||||||
raise TimeoutError() from e
|
raise TimeoutError() from e
|
||||||
except (BrokenPipeError, ConnectionAbortedError):
|
except ConnectionError:
|
||||||
self._raise_connection_reset()
|
self._raise_connection_reset()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EBADF:
|
if e.errno == errno.EBADF:
|
||||||
|
@ -139,10 +139,7 @@ class TcpClient:
|
||||||
partial = self._socket.recv(bytes_left)
|
partial = self._socket.recv(bytes_left)
|
||||||
except socket.timeout as e:
|
except socket.timeout as e:
|
||||||
raise TimeoutError() from e
|
raise TimeoutError() from e
|
||||||
except ConnectionAbortedError:
|
except ConnectionError:
|
||||||
# ConnectionAbortedError: [WinError 10053]
|
|
||||||
# An established connection was aborted by
|
|
||||||
# the software in your host machine.
|
|
||||||
self._raise_connection_reset()
|
self._raise_connection_reset()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EBADF or e.errno == errno.ENOTSOCK:
|
if e.errno == errno.EBADF or e.errno == errno.ENOTSOCK:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user