Add: Start govel build packages
This commit is contained in:
parent
865ec5def5
commit
c26fcdc1db
18 changed files with 37 additions and 26 deletions
|
|
@ -1,44 +0,0 @@
|
|||
#
|
||||
# Erminig - Décorateur pour relancer un téléchargement
|
||||
# Copyright (C) 2025 L0m1g
|
||||
# Sous licence DOUARN - Voir le fichier LICENCE pour les détails
|
||||
#
|
||||
# Ce fichier fait partie du projet Erminig.
|
||||
# Libre comme l’air, stable comme un menhir, et salé comme le beurre.
|
||||
#
|
||||
|
||||
|
||||
import time
|
||||
import requests
|
||||
from erminig.config import Config
|
||||
|
||||
|
||||
def retry_on_failure():
|
||||
def decorator(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
attempt = 1
|
||||
while attempt <= Config.RETRY_MAX_ATTEMPTS + 1:
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except requests.exceptions.RequestException as e:
|
||||
name = getattr(args[0], "name", "Unknown")
|
||||
print(
|
||||
f"[{name}] Erreur réseau tentative {attempt}: {e.__class__.__name__}"
|
||||
)
|
||||
if attempt <= Config.RETRY_MAX_ATTEMPTS:
|
||||
print(
|
||||
f"[{name}] Nouvelle tentative dans {Config.RETRY_DELAY_SECONDS}s..."
|
||||
)
|
||||
time.sleep(Config.RETRY_DELAY_SECONDS)
|
||||
attempt += 1
|
||||
else:
|
||||
print(f"[{name}] Abandon après {attempt} tentatives.")
|
||||
return None
|
||||
except Exception as e:
|
||||
name = getattr(args[0], "name", "Unknown")
|
||||
print(f"[{name}] Erreur inconnue dans {func.__name__}: {e}")
|
||||
return None
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
Loading…
Add table
Add a link
Reference in a new issue