Added Ruff linting
This commit is contained in:
1 parent
a96c6db97d
commit
fa9eb3d323
6 files changed
+57
-23
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import requests
|
||||
from requests.exceptions import RequestException, Timeout, ConnectionError, HTTPError
|
||||
from fastapi import HTTPException
|
||||
from secret_manager import return_credentials
|
||||
import os
|
||||
import time
|
||||
from simple_logger_handler import setup_logger
|
||||
|
||||
import requests
|
||||
from fastapi import HTTPException
|
||||
from requests.exceptions import ConnectionError, HTTPError, RequestException, Timeout
|
||||
|
||||
from secret_manager import return_credentials
|
||||
from simple_logger_handler import setup_logger
|
||||
|
||||
backend_api_url=os.getenv("BACKEND_API_URL","localhost:8101/internal/receive-notifications")
|
||||
api_key= return_credentials("/etc/secrets/api_key")
|
||||
@@ -53,15 +54,15 @@ def send_notification(title: str, chapter_title: str,link: str,max_retries: int
|
||||
logger.warning(f"[Notify] Attempt {attempt}/{max_retries} failed: {type(e).__name__}")
|
||||
if attempt == max_retries:
|
||||
logger.error(f"[Notify] All retry attempts failed for '{title}'")
|
||||
raise HTTPException(status_code=503, detail=f"Notification service unavailable: {type(e).__name__}")
|
||||
raise HTTPException(status_code=503, detail=f"Notification service unavailable: {type(e).__name__}") from e
|
||||
sleep_time = 2 ** (attempt - 1)
|
||||
logger.debug(f"[Notify] Retrying in {sleep_time} seconds...")
|
||||
time.sleep(sleep_time)
|
||||
|
||||
except HTTPError as e:
|
||||
logger.error(f"[Notify] HTTP {e.response.status_code}: {e.response.text}")
|
||||
raise HTTPException(status_code=e.response.status_code, detail=e.response.text)
|
||||
raise HTTPException(status_code=e.response.status_code, detail=e.response.text) from e
|
||||
|
||||
except RequestException as e:
|
||||
logger.error(f"[Notify] Unexpected request failure: {e}")
|
||||
raise HTTPException(status_code=500, detail=f"Request failed: {str(e)}")
|
||||
raise HTTPException(status_code=500, detail=f"Request failed: {str(e)}") from e
|
||||
Reference in new issue
Block a user