|
@@ -10,7 +10,15 @@ pip install tenacity
|
|
|
|
|
|
import tenacity
|
|
import tenacity
|
|
|
|
|
|
-@tenacity.retry
|
|
|
|
|
|
+max_tries = 60 * 5 # 5 minutes
|
|
|
|
+wait_seconds = 1
|
|
|
|
+
|
|
|
|
+@tenacity.retry(
|
|
|
|
+ stop=stop_after_attempt(max_tries),
|
|
|
|
+ wait=wait_fixed(wait_seconds),
|
|
|
|
+ before=before_log(logger, logging.INFO),
|
|
|
|
+ after=after_log(logger, logging.WARN),
|
|
|
|
+)
|
|
def fetch_data(url):
|
|
def fetch_data(url):
|
|
response = requests.get(url)
|
|
response = requests.get(url)
|
|
response.raise_for_status()
|
|
response.raise_for_status()
|