Sidoineko commited on
Commit
edb4ee9
·
1 Parent(s): b208ec3

Create hf_timeout.py

Browse files
Files changed (1) hide show
  1. hf_timeout.py +27 -0
hf_timeout.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ import requests
4
+
5
+ def wait_for_model_loading():
6
+ """Attend que le modèle soit chargé"""
7
+ max_retries = 30 # 30 tentatives maximum
8
+ retry_delay = 60 # 60 secondes entre chaque tentative
9
+
10
+ for i in range(max_retries):
11
+ try:
12
+ # Vérifie si l'application répond
13
+ response = requests.get("http://localhost:8501/_stcore/health", timeout=10)
14
+ if response.status_code == 200:
15
+ print("L'application est prête !")
16
+ return True
17
+ except:
18
+ pass
19
+
20
+ print(f"En attente du chargement de l'application... (tentative {i+1}/{max_retries})")
21
+ time.sleep(retry_delay)
22
+
23
+ print("Délai d'attente dépassé. Vérifiez les logs pour plus d'informations.")
24
+ return False
25
+
26
+ if __name__ == "__main__":
27
+ wait_for_model_loading()