Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import re
import time
from datetime import datetime, timezone
from functools import wraps

import requests
import schedule
from dotenv import load_dotenv
from tenacity import before_sleep_log, retry, stop_after_attempt, wait_fixed

from config import load_config
from constants import PRIORITY_TO_SCORE
Expand Down Expand Up @@ -93,23 +93,14 @@ def with_retries(func):
exception and waits RETRY_SLEEP_SECONDS before retrying. After the final
attempt, the last exception is re-raised.
"""
@wraps(func)
def wrapper(*args, **kwargs):
for attempt in range(MAX_RETRY_COUNT):
try:
return func(*args, **kwargs)
except Exception as e:
logging.error(
"Function %s failed with exception %s",
func.__name__,
type(e).__name__,
exc_info=True,
)
if attempt == MAX_RETRY_COUNT - 1:
raise
time.sleep(RETRY_SLEEP_SECONDS)

return wrapper
logger = logging.getLogger(__name__)
retry_decorator = retry(
reraise=True,
stop=stop_after_attempt(MAX_RETRY_COUNT),
wait=wait_fixed(RETRY_SLEEP_SECONDS),
before_sleep=before_sleep_log(logger, logging.ERROR),
)
return retry_decorator(func)


def get_team_members(team_slug: str):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ aiohttp==3.12.14
aiosignal==1.4.0
anyio==4.8.0
attrs==25.1.0
backoff==2.2.1
black==25.1.0
blinker==1.9.0
botocore==1.36.12
Expand Down Expand Up @@ -41,6 +40,7 @@ requests-toolbelt==1.0.0
schedule==1.2.2
six==1.17.0
sniffio==1.3.1
tenacity==8.2.3
typing_extensions==4.12.2
urllib3==2.6.0
websockets==11.0.3
Expand Down