bluesky_queueserver_api.zmq.REManagerAPI.send_request¶
- REManagerAPI.send_request(*, method, params=None)¶
Send request to RE Manager and receive the response. The function directly passes the request to low-level Queue Server API (0MQ) or sends formatted request to the server (HTTP). The detailed description of available methods, including names, parameters and returned values, can be found in Queue Server API reference. The function raises
RequestTimeoutError` in case of communication timeout. Depending on ``REManagerAPI
configuration (request_fail_exceptions
parameter), the API raisesRequestFailedError
if the request is rejected by the Queue Server or returns result to the calling function.- Parameters:
- method: str, list or tuple
Name of the API method (e.g.
'status'`, 0MQ and HTTP requests) or a tuple (e.g. ``('GET', '/api/status')
, only HTTP requests). Tuple should be used to call custom REST API that are not supported by the library.- params: dict or None, optional
Dictionary of API parameters or
None
if no parameters are passed.- headers: dict or None, optional
Header data (supported only for HTTP requests). Default: None.
- data: dict or None, optional
Form data (supported only for HTTP requests). Default: None.
- timeout: float or None, optional
Timeout in seconds (supported only for HTTP requests). If the value is zero or negative, then timeout is diabled. The default timeout is used if the value is
None
. Default: None.- auto_refresh_session: boolean, optional
Indicates if the session should be automatically refreshed if the token expired (supported only for HTTP requests). The session could be refreshed only if an expired access token and valid refresh token are available. The option to refresh session should be enabled for most API that require authentication. Default: True.
- Returns:
- dict
Dictionary with the returned results.
- Raises:
- RequestTimeoutError
Communication timed out.
- RequestFailedError
Request failed or rejected by the Queue Server (the response contains
"success": False
).- HTTPRequestError, HTTPClientError, HTTPServerError
Error while processing the request or communicating with the server. Raised only by HTTP requests.
Examples
# Synchronous code (0MQ) from bluesky_queueserver_api.zmq import REManagerAPI RM = REManagerAPI() status = RM.send_request(method="status") RM.close() # Synchronous code (HTTP) from bluesky_queueserver_api.http import REManagerAPI RM = REManagerAPI() status = RM.send_request(method="status") RM.close() # Asynchronous code (0MQ) from bluesky_queueserver_api.zmq.aio import REManagerAPI RM = REManagerAPI() status = await RM.send_request(method="status") await RM.close() # Asynchronous code, (HTTP) from bluesky_queueserver_api.http.aio import REManagerAPI RM = REManagerAPI() status = await RM.send_request(method="status") await RM.close()