bluesky_queueserver_api.zmq.REManagerAPI.wait_for_completed_task

REManagerAPI.wait_for_completed_task(task_uid, *, timeout=600, monitor=None, treat_not_found_as_completed=True)

Wait for one or multiple tasks to be completed. The function takes a single task UID (string) or a number of task UIDs (any iterable) and returns a dictionary that maps UIDs of completed tasks to their status. The status may be 'completed' or 'not_found' (if treat_not_found_as_completed is True). The task has a status 'not_found' if it was completed long ago and removed from the dictionary of task results, so it is reasonable to consider such tasks as completed in most cases.

In addition to typical WaitTimeoutError and WaitCancelError exceptions, the function may raises exceptions while calling REManagerAPI.task_status() API before and after wait. If the server can not be reached or the request fails, the respective exception is raised.

Parameters:
task_uid: str or Iterable

One task UID represented as a string or one or several task UIDs represented as an iterable of strings (list, set etc). The value must be non-empty string or Iterable with at least one element.

timeout: float (optional)

Floating point number representing timeout in seconds.

monitor: bluesky_queueserver_api.WaitMonitor or None (optional)

Instance of WaitMonitor. See documentation for REManagerAPI.wait_for_idle() for more details.

treat_not_found_as_completed: boolean (default: True)

The tasks with status 'not_found' are considered completed if the value is True (default). This is correct assumption for most practical situations. Set the parameter to False to wait for completion of the tasks that are not in the list of results.

Returns:
dict(str: str)

A dictionary where the keys are UIDs of completed tasks and the values represent status of the tasks.

Raises:
REManagerAPI.WaitTimeoutError, REManagerAPI.WaitCancelError

The manager did not switch to ‘idle’ state during the timeout period or wait was cancelled using monitor.cancel().

RequestTimeoutError, RequestFailedError, HTTPRequestError, HTTPClientError, HTTPServerError

All exceptions raised by send_request API.

RequestParameterError

Invalid parameter value or type

Examples

The code in the following example starts three functions, waits for for execution of all functions, read and stores the execution results in the process. It is advised to load the execution results as they become available, otherwise they may expired and get deleted by the server.

Synchronous code:

Asynchronous code: