Skip to content

Commit

Permalink
Updated retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
volbil committed May 21, 2024
1 parent 7ef8f60 commit cc0eabc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions kibun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ async def kibun_loop(tasks, semaphore_number=1):
if task_result.success:
continue

# Do not retry task if it's failed with non retry status
if task_result.status not in task_result.task.retry_status:
continue

# Stop after task failed more than max_fails
if task_result.task.max_fails is not None:
if task_result.task.fails > task_result.task.max_fails:
Expand Down
2 changes: 1 addition & 1 deletion kibun/backend/aio/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def request_aio(session, endpoint, task):
attempts += 1

# There is no need to spam generic error messages
if status not in [constants.NETWORK_ERROR]:
if status not in task.retry_status:
logger.error(f"Request failed {endpoint} {status} ({attempts})")

if task.sleep > 0:
Expand Down

0 comments on commit cc0eabc

Please sign in to comment.