fermioniq.client.Client.subscribe_to_events#
- Client.subscribe_to_events(job_id: str, on_msg_callback: Callable[[EmulatorMessage], None] | None = None, return_as_task: bool = False, cancel_on_interrupt: bool = False, log_updates: bool = False, logger: Callable[[str], None] | None = None) None | Task[None] #
Subscribe to job events and execute a callback function when a new message is received.
- Parameters:
- job_id
The ID of the job to subscribe to.
- on_msg_callback
A callback function to be executed when a new message is received.
- return_as_task
If True, returns the task instead of executing it immediately.
- cancel_on_interrupt
If True, and return_as_task is False, the job will be cancelled on Keyboard interrupt signal.
- log_updates
If True, live updates will be printed via
logger
, or a default logger iflogger
is not set.- logger
Logger to use for live updates (if set).
- Returns:
- task
None if return_as_task is False, otherwise an asyncio.Task object.