Skip to content

Commit

Permalink
portal: catch lambda queue error
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Apr 19, 2022
1 parent 657f91c commit 995f05b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Expand Up @@ -404,7 +404,7 @@ function prep_download(query, prefix) {

$('a[name="download"]').click(function(e) {
$('a[name="download"]').addClass("is-hidden");
$('a[name="include"]').addClass("is-hidden");
$('input[name="include"]').parent(".dropdown-item").addClass("is-hidden");
$(this).addClass('is-loading').removeClass("is-hidden");
const fmt = $(this).data('format');
const include = $('input[name="include"]:checked').map(function() {
Expand Down
30 changes: 18 additions & 12 deletions mpcontribs-portal/mpcontribs/portal/views.py
Expand Up @@ -498,26 +498,32 @@ def make_download(headers, query, include=None):
status = redis_store.get(redis_key)

if status is None:
payload={
payload = {
"redis_key": redis_key,
"host": os.environ["MPCONTRIBS_CLIENT_HOST"],
"headers": headers,
"query": query,
"include": include
}
response = lambda_client.invoke(
FunctionName='MPContribsMakeDownloadFunction',
InvocationType='Event',
Payload=payload
)
if response["StatusCode"] == 202:
status = "SUBMITTED"
json_resp["status"] = status
redis_store.set(redis_key, status)
else:
try:
response = lambda_client.invoke(
FunctionName="mpcontribs-make-download",
InvocationType='Event',
Payload=json.dumps(payload)
)
if response["StatusCode"] == 202:
status = "SUBMITTED"
json_resp["status"] = status
redis_store.set(redis_key, status)
else:
status = "ERROR"
json_resp["status"] = status
json_resp["error"] = "Failed to queue download request"
redis_store.set(redis_key, status)
except Exception as e:
status = "ERROR"
json_resp["status"] = status
json_resp["error"] = "Failed to queue download request"
json_resp["error"] = str(e)
redis_store.set(redis_key, status)
else:
json_resp["status"] = status
Expand Down

0 comments on commit 995f05b

Please sign in to comment.