Except IOError and not ConnectionError

PySocks' errors do not subclass ConnectionError so the library
was unnecessarily logging them as unexpected, when any IOError
was actually expected.
This commit is contained in:
Lonami Exo
2019-03-28 09:52:46 +01:00
parent c902428af1
commit 7523869875
3 changed files with 10 additions and 7 deletions

View File

@@ -115,7 +115,10 @@ class InteractiveTelegramClient(TelegramClient):
print('Connecting to Telegram servers...')
try:
loop.run_until_complete(self.connect())
except ConnectionError:
except IOError:
# We handle IOError and not ConnectionError because
# PySocks' errors do not subclass ConnectionError
# (so this will work with and without proxies).
print('Initial connection failed. Retrying...')
loop.run_until_complete(self.connect())