commit fixes

This commit is contained in:
yash-dk 2020-09-13 02:20:18 +05:30
parent 4041f417f4
commit fdde26551b
2 changed files with 7 additions and 7 deletions

View File

@ -102,12 +102,11 @@ def retry_range(retries, force_retry=True):
infinite, otherwise it will end at `retries + 1`.
"""
# We need atleast one iteration even if the retries are 0
# when force_retry is True.
if retries == 0 and force_retry:
yield 1
# We need at least one iteration even if the retries are 0
# when force_retry is True.
if force_retry:
retries+=1
# If retries are non 0 then iterate
attempt = 0
while attempt != retries:
attempt += 1

View File

@ -360,13 +360,14 @@ class MTProtoSender:
retries = self._retries if self._auto_reconnect else 0
attempt = 0
for attempt in retry_range(retries, False):
# 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__)
attempt, e.__class__.__name__)
await asyncio.sleep(self._delay)
except Exception as e:
last_error = e