bluesky_queueserver_api.zmq.REManagerAPI.task_result

REManagerAPI.task_result(task_uid)

Get the status and results of task execution. The completed tasks are stored at the server at least for the period determined by retention time (currently 120 seconds after completion of the task). The expired results could be automatically deleted at any time and the method will return the task status as "not_found".

Parameters:
task_uid: str

A single task UID.

Returns:
dict

Dictionary keys:

  • success: boolean - success of the request.

  • msg: str - error message in case the request is rejected by RE Manager.

  • task_uid: str - task UID.

  • status: str or None - status of the task (“running”, “completed”, “not_found”) or None if the request (not task) fails.

  • result: dict or None - dictionary containing the information on a running task, results of execution of the completed task or None if the request failed. The contents of the dictionary depends on the returned status: "running" (keys: task_uid, start_time and run_in_background), "completed" (keys: task_uid, success - True/False, msg - error message, return_value - value returned by the function or a string with full traceback if the task failed, time_start and time_stop), "not_found" - empty dictionary.

Raises:
RequestTimeoutError, RequestFailedError, HTTPRequestError, HTTPClientError, HTTPServerError

All exceptions raised by send_request API.

RequestParameterError

Invalid parameter value or type

Examples

function = BFunc("function_sleep", 10)

# Synchronous code (0MQ, HTTP)
reply = RM.function_execute(function)
task_uid = reply["task_uid"]
reply = RM.task_result(task_uid)
task_status = reply["status"]
task_result = reply["result"]

# Asynchronous code (0MQ, HTTP)
await RM.function_execute(function)
reply = await RM.function_execute(function)
task_uid = reply["task_uid"]
reply = await RM.task_result(task_uid)
task_status = reply["status"]
task_result = reply["result"]