bluesky_queueserver_api.console_monitor.ConsoleMonitor_ZMQ_Threads.next_msg

ConsoleMonitor_ZMQ_Threads.next_msg(timeout=None)

Returns the next message from the buffer. If timeout is None or zero, then the API returns the next available message. If the buffer contains no messages, the function waits for the next published message for timeout period and raises RequestTimeoutError if no messages were received. If timeout is ``None or zero and the buffer contains no messages, then the function immediately raises RequestTimeoutError.

Parameters:
timeout: float or None

If timeout is positive floating point number, zero or None.

Raises:
RequestTimeoutError

No messages were no messages received during timeout period.

Examples

Synchronous API:

# Make sure RE Manager is started with option '--zmq-publish-console=ON'

RM = REManagerAPI()
RM.console_output.enable()

# Run any command that generates console output
RM.environment_open()
RM.wait_for_idle()

try:
    msg = RM.console_output.next_msg()
    print(msg["msg"], end="")
except RM.RequestTimeoutError:
    pass

RM.console_output.disable()
RM.close()

Asynchronous API:

# Make sure RE Manager is started with option '--zmq-publish-console=ON'

RM = REManagerAPI()
RM.console_output.enable()

# Run any command that generates console output
await RM.environment_open()
await RM.wait_for_idle()

try:
    msg = await RM.console_output.next_msg()
    print(msg["msg"], end="")
except RM.RequestTimeoutError:
    pass

RM.console_output.disable()
await RM.close()