bluesky_queueserver.ZMQCommSendAsync
- class bluesky_queueserver.ZMQCommSendAsync(*, loop=None, zmq_server_address=None, timeout_recv=2000, timeout_send=500, raise_exceptions=True, server_public_key=None)[source]
API for communication with RE Manager via ZMQ. The object has to be created from the running even loop or the loop has to be passed as a parameter during initialization.
- Parameters:
- loopasyncio loop
Current event loop
- zmq_server_addressstr or None
Address of ZMQ server. If None, then the default address is
tcp://localhost:60615
is used.- timeout_recvint
Timeout (in ms) for ZMQ receive operations.
- timeout_send: int
Timeout (in ms) for ZMQ send operations.
- raise_exceptionsbool
Tells if exceptions should be raised in case of communication errors (mostly timeouts) when
send_message()
is awaited. This setting can be overridden by specifyingraise_exceptions
parameter ofsend_message()
function. The exceptionCommTimeoutError
is raised if the parameter isTrue
, otherwise error message is returned bysend_message()
.- server_public_keystr or None
Server public key (z85-encoded 40 character string). The valid public key from the server public/private key pair must be passed if encryption is enabled at the 0MQ server side. Communication requests will time out if the key is invalid. Exception will be raised if the key is improperly formatted. Encryption will be disabled if
None
is passed.
Examples
async def communicate(): zmq_comm = ZMQCommSendAsync() for n in range(10): msg = await zmq_comm.send_message(method="some_method", params={"some_value": n}) print(f"msg={msg}") zmq_comm.close() asyncio.run(communicate())
- __init__(*, loop=None, zmq_server_address=None, timeout_recv=2000, timeout_send=500, raise_exceptions=True, server_public_key=None)[source]
Methods
__init__
(*[, loop, zmq_server_address, ...])close
()Close ZMQ socket.
get_loop
()Returns the asyncio event loop.
send_message
(*, method[, params, timeout, ...])Send message to ZMQ server and wait for the response.