mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Consider all reconnect attempts as retrying (#1557)
This means that a value of 0 retries will no longer try to reconnect.
This commit is contained in:
@@ -217,6 +217,7 @@ class MTProtoSender:
|
||||
self._log.info('Connecting to %s...', self._connection)
|
||||
|
||||
connected = False
|
||||
|
||||
for attempt in retry_range(self._retries):
|
||||
if not connected:
|
||||
connected = await self._try_connect(attempt)
|
||||
@@ -357,14 +358,16 @@ class MTProtoSender:
|
||||
self._state.reset()
|
||||
|
||||
retries = self._retries if self._auto_reconnect else 0
|
||||
for attempt in retry_range(retries):
|
||||
|
||||
attempt = 0
|
||||
# We're already "retrying" to connect, so we don't want to force retries
|
||||
for attempt in retry_range(retries, force_retry=False):
|
||||
try:
|
||||
await self._connect()
|
||||
except (IOError, asyncio.TimeoutError) as e:
|
||||
last_error = e
|
||||
self._log.info('Failed reconnection attempt %d with %s',
|
||||
attempt, e.__class__.__name__)
|
||||
|
||||
await asyncio.sleep(self._delay)
|
||||
except Exception as e:
|
||||
last_error = e
|
||||
|
Reference in New Issue
Block a user