Commit f26019ef authored by Alessandro CERIONI's avatar Alessandro CERIONI
Browse files

Retrying in case response_code != 200

parent dcd8ff06
......@@ -3,6 +3,7 @@ import subprocess
import hashlib
import codecs
import os
import time
from yaml import load, dump
try:
......@@ -35,8 +36,19 @@ def refresh_cache():
# if file_found == False or age > 86400:
print('Fetching a new file...')
res = requests.get(url)
print('Done.')
done = False
while not done:
res = requests.get(url)
if res.status_code != 200:
print('Something went wrong. Sleeping for 5 seconds before retrying...')
time.sleep(5)
done = False
else:
print('Done.')
done = True
break
if not os.path.exists(working_directory):
os.makedirs(working_directory)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment