bluesky_queueserver_api.zmq.REManagerAPI.task_status

REManagerAPI.task_status(task_uid)

Returns the status of one or more tasks executed by the worker process. The request must contain one or more valid task UIDs, returned by one of APIs that starts tasks. A single UID may be passed as a string, multiple UIDs must be passed as as a list of strings. If a UID is passed as a string, then the returned status is also a string, if a list of one or more UIDs is passed, then the status is a dictionary that maps task UIDs and their status. 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 or Iterable(str)

A single task UID (str) or an iterable (list, tuple, set etc.) of one or multiple UIDs.

Returns:
response: dict

Dictionary keys:

  • success: boolean - success of the request.

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

  • task_uid - returns UID(s) passed to the function.

  • status - status of the task(s) or None if the request (not task) failed. If task_uid is a string representing single UID, then the status is a string from the set {"running", "completed", "not_found"}. If task_uid is a list of strings, then status is a dictionary that maps task UIDs to status of the respective tasks.

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"]
# Status of a single task
reply = RM.task_status(task_uid)
task_status = reply["status"]
# Same result, but allows to submit multiple task UIDs
reply = RM.task_status([task_uid])
task_status = reply["status"][task_uid]

# Asynchronous code (0MQ, HTTP)
await RM.function_execute(function)
reply = await RM.function_execute(function)
task_uid = reply["task_uid"]
# Status of a single task
reply = await RM.task_status(task_uid)
task_status = reply["status"]
# Same result, but allows to submit multiple task UIDs
reply = await RM.task_status([task_uid])
task_status = reply["status"][task_uid]