bluesky_queueserver.ZMQCommSendThreads.send_message

ZMQCommSendThreads.send_message(*, method, params=None, timeout=None, cb=None, raise_exceptions=None)[source]

Send message to ZMQ server and wait for the response. The message must contain a name of a method supported by the server and a dictionary of parameters that are required by the method. In case of communication error (timeout), the function returns error message or raises CommTimeoutError exception depending on the values raise_exceptions parameter in this function and class constructor.

Parameters:
method: str

Name of the method to be invoked on the server. The method must be supported by the server.

params: dict or None

Dictionary of parameters passed to the method. If None, then an empty dictionary is passed to the server.

timeout: int or None

Read timeout (in ms) for the single request. If None, then the default timeout is used.

cb: callable or None

Callback function. If None, then the function blocks until communication is complete. Otherwise the function exits after the message is sent to the server. The callback is called when the response is received or timeout occurs. Function signature is cb(msg: dict, msg_err: str). Here msg is the dictionary of the parameters returned by the server and msg_err is "" if communication was successful and contains error message in case communication failed (timeout).

raise_exceptions: bool or None

The flag indicates if exception should be raised in case of communication error (such as timeout). If False, then error message is returned instead. If None, then the field value self._raise_timeout_exceptions is used to determine if the exception needs to be raised. Non-blocking calls do not raise the exception. Instead, callback function receives the error message as one of the parameters

Returns:
dict

Message returned by the server.

Raises:
CommTimeoutError

Raised if communication error occurs and raise_exceptions is set True.