Skip to content

Commit c32fe15

Browse files
committed
retry flusurv on temporary failure
- add a delay and retry when flusurv returns 500 - remove extraneous debugging
1 parent 260ca49 commit c32fe15

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/acquisition/flusurv/flusurv.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# standard library
3939
from datetime import datetime
4040
import json
41+
import time
4142

4243
# third party
4344
import requests
@@ -74,7 +75,7 @@
7475
}
7576

7677

77-
def fetch_json(path, payload):
78+
def fetch_json(path, payload, call_count=1):
7879
"""Send a request to the server and return the parsed JSON response."""
7980

8081
# it's polite to self-identify this "bot"
@@ -102,7 +103,13 @@ def fetch_json(path, payload):
102103
resp = method(flusurv_url, headers=headers, data=data)
103104

104105
# check the HTTP status code
105-
if resp.status_code != 200:
106+
if resp.status_code == 500 and call_count <= 2:
107+
# the server often fails with this status, so wait and retry
108+
delay = 10 * call_count
109+
print('got status %d, will retry in %d sec...' % (resp.status_code, delay))
110+
time.sleep(delay)
111+
return fetch_json(path, payload, call_count=call_count + 1)
112+
elif resp.status_code != 200:
106113
raise Exception(['status code != 200', resp.status_code])
107114

108115
# check response mine type

src/acquisition/fluview/impute_missing_values.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ def get_fusion_parameters(known_locations):
291291
H = graph[is_known, :]
292292
W = graph[is_unknown, :]
293293
if np.linalg.matrix_rank(H) != len(atoms):
294-
print(np.linalg.matrix_rank(H))
295294
raise Exception('system is underdetermined')
296295

297296
HtH = np.dot(H.T, H)

0 commit comments

Comments
 (0)