Skip to content

Commit

Permalink
automated push from 607640e3c4c14b8f7c4087c6a1b1f54f6f11a15e
Browse files Browse the repository at this point in the history
  • Loading branch information
Vic Putz committed Nov 5, 2020
1 parent f3c3c6d commit 2ad17c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion qcware/api_calls/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .api_call import api_call, post_call, wait_for_call, handle_result, retrieve_result, async_retrieve_result
from .api_call import (api_call, post_call, wait_for_call, handle_result,
retrieve_result, async_retrieve_result, status, cancel)
23 changes: 22 additions & 1 deletion qcware/api_calls/api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ def api_call(api_call_context: ApiCallContext, call_token: str):
return post(f'{api_call_context["qcware_host"]}/api_calls', locals())


def status(call_token: str):
api_call_context = current_context()
api_call_context = api_call_context.dict()
do_client_api_compatibility_check_once()
return post(f'{api_call_context["qcware_host"]}/api_calls/status',
locals())


def cancel(call_token: str):
api_call_context = current_context()
api_call_context = api_call_context.dict()
do_client_api_compatibility_check_once()
return post(f'{api_call_context["qcware_host"]}/api_calls/cancel',
locals())


def _print_waiting_handler(details: Dict):
pass

Expand Down Expand Up @@ -63,10 +79,15 @@ def handle_result(api_call):
raise ApiCallExecutionError(result['error'],
traceback=api_call.get('data', {}).get(
'stack_trace', 'no traceback'))
elif api_call['state'] == 'scheduled':
# if it's scheduled, try to raise a nice rescheduled ApiCallExecutionError
schedule_at_str = api_call.get('schedule_at_str', "unscheduled")
raise ApiCallExecutionError(f"Rescheduled for {schedule_at_str}",
traceback="")
# if we've got to this point, we either have a result (state == 'success') or we have
# some other result (state == error, open, new). If that's the case, we've likely
# timed out
if api_call['state'] in ['error', 'open', 'new']:
if api_call['state'] in ['open', 'new']:

api_call_info = {
k: api_call.get(k, None)
Expand Down

0 comments on commit 2ad17c5

Please sign in to comment.