From 2ffe2b71dc019792c4b34c5ed070e9299021a461 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 3 Feb 2018 11:39:15 +0100 Subject: [PATCH] Except OSError with errno.WSAEACCES when connecting "OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions." --- telethon/extensions/tcp_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/extensions/tcp_client.py b/telethon/extensions/tcp_client.py index d4c45776..a306302a 100644 --- a/telethon/extensions/tcp_client.py +++ b/telethon/extensions/tcp_client.py @@ -73,7 +73,8 @@ class TcpClient: # There are some errors that we know how to handle, and # the loop will allow us to retry if e.errno in (errno.EBADF, errno.ENOTSOCK, errno.EINVAL, - errno.ECONNREFUSED): + errno.ECONNREFUSED, # Windows-specific follow + getattr(errno, 'WSAEACCES', None)): # Bad file descriptor, i.e. socket was closed, set it # to none to recreate it on the next iteration self._socket = None