mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-02 03:00:15 +03:00
commit fixes
This commit is contained in:
parent
4041f417f4
commit
fdde26551b
|
@ -102,12 +102,11 @@ def retry_range(retries, force_retry=True):
|
||||||
infinite, otherwise it will end at `retries + 1`.
|
infinite, otherwise it will end at `retries + 1`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# We need atleast one iteration even if the retries are 0
|
# We need at least one iteration even if the retries are 0
|
||||||
# when force_retry is True.
|
# when force_retry is True.
|
||||||
if retries == 0 and force_retry:
|
if force_retry:
|
||||||
yield 1
|
retries+=1
|
||||||
|
|
||||||
# If retries are non 0 then iterate
|
|
||||||
attempt = 0
|
attempt = 0
|
||||||
while attempt != retries:
|
while attempt != retries:
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
|
@ -360,13 +360,14 @@ class MTProtoSender:
|
||||||
retries = self._retries if self._auto_reconnect else 0
|
retries = self._retries if self._auto_reconnect else 0
|
||||||
|
|
||||||
attempt = 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:
|
try:
|
||||||
await self._connect()
|
await self._connect()
|
||||||
except (IOError, asyncio.TimeoutError) as e:
|
except (IOError, asyncio.TimeoutError) as e:
|
||||||
last_error = e
|
last_error = e
|
||||||
self._log.info('Failed reconnection attempt %d with %s',
|
self._log.info('Failed reconnection attempt %d with %s',
|
||||||
attempt, e.__class__.__name__)
|
attempt, e.__class__.__name__)
|
||||||
await asyncio.sleep(self._delay)
|
await asyncio.sleep(self._delay)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
last_error = e
|
last_error = e
|
||||||
|
|
Loading…
Reference in New Issue
Block a user