Skip to content

Commit ccd6a11

Browse files
committed
skip over chunks that result in 400 client error responses
1 parent 8d9739c commit ccd6a11

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/local_assignment_multi.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,13 @@ def request_assignments(subscription_plan_uuid, chunk_id, emails_for_chunk, envi
243243
response.raise_for_status()
244244
except requests.exceptions.HTTPError:
245245
# if it's a 401, try refetching the JWT and re-try the request
246+
print(response.content)
246247
if response.status_code == 401:
247248
print('EXPIRED JWT, REFETCHING...')
248249
response = _post_assignments(subscription_plan_uuid, emails_for_chunk, environment, fetch_jwt)
249250
response.raise_for_status()
250251
else:
251-
raise
252+
print('Continuing past this exception.')
252253

253254
response_data = response.json()
254255

@@ -288,9 +289,14 @@ def do_assignment_for_chunk(
288289

289290
results_for_chunk = []
290291
if payload_for_chunk:
291-
results_for_chunk = request_assignments(
292-
subscription_plan_uuid, chunk_id, payload_for_chunk, environment, fetch_jwt,
293-
)
292+
try:
293+
results_for_chunk = request_assignments(
294+
subscription_plan_uuid, chunk_id, payload_for_chunk, environment, fetch_jwt,
295+
)
296+
except Exception as exc:
297+
print(exc)
298+
print('continuing on...')
299+
return
294300
with open(results_file, 'a+') as f_out:
295301
writer = csv.writer(f_out, delimiter=',')
296302
writer.writerows(results_for_chunk)

0 commit comments

Comments
 (0)