mirror of
https://codeberg.org/Freedium-cfd/web.git
synced 2026-03-11 09:04:37 +00:00
Fixing sleep time on retry
This commit is contained in:
parent
5a05864aae
commit
5103f1bd0e
1 changed files with 6 additions and 6 deletions
|
|
@ -102,17 +102,13 @@ class MediumParser:
|
|||
post_data, is_cache_used = None, False
|
||||
|
||||
attempt = 0
|
||||
reason = None
|
||||
while not post_data and attempt < retry:
|
||||
try:
|
||||
post_data, is_cache_used = await self.query_get(use_cache)
|
||||
except Exception as e:
|
||||
logger.error(f"Attempt {attempt + 1} failed with exception: {e}")
|
||||
finally:
|
||||
logger.info(f"Retrying in {2 ** attempt} seconds...")
|
||||
await asyncio.sleep(2 ** attempt)
|
||||
attempt += 1
|
||||
|
||||
reason = None
|
||||
continue
|
||||
|
||||
if not post_data:
|
||||
reason = "No post data returned"
|
||||
|
|
@ -127,6 +123,10 @@ class MediumParser:
|
|||
|
||||
if reason is None:
|
||||
break
|
||||
|
||||
logger.info(f"Retrying in {2 ** attempt} seconds...")
|
||||
await asyncio.sleep(2 ** attempt)
|
||||
attempt += 1
|
||||
else:
|
||||
if not reason:
|
||||
reason = "Unknown"
|
||||
|
|
|
|||
Loading…
Reference in a new issue