Skip to content

Python Core API Subscribe And Poll

poll(recording_time_s, timeout_ms, flags=0, flat=False)

Poll all Events available before and within an given time period.

Continuously check for value changes (by calling pollEvent) in all subscribed nodes for the specified duration and return the data. If no value change occurs in subscribed nodes before duration + timeout, poll returns no data. This function call is blocking (it is synchronous). However, since all value changes are returned since either subscribing to the node or the last poll (assuming no buffer overflow has occurred on the Data Server), this function may be used in a quasi-asynchronous manner to return data spanning a much longer time than the specified duration. The timeout parameter is only relevant when communicating in a slow network. In this case it may be set to a value larger than the expected round-trip time in the network.

Parameters:

Name Type Description Default
recording_time_s float

Recording time in [s]. The function will block during that time.

required
timeout_ms int

Poll timeout in [ms]. Recommended value is 500ms.

required
flags int

Poll flags. DEFAULT = 0x0000: Default. FILL = 0x0001: Fill holes. THROW = 0x0004: Throw EOFError exception if sample loss is detected (only possible in combination with DETECT). DETECT = 0x0008: Detect data loss holes.

0
flat bool

Specify which type of data structure to return. Return data either as a flat dict (True) or as a nested dict tree (False). Default = False.

False

Returns:

Type Description
Dict[str, LabOneResultAny]

A dict with the polled events. (Empty if no event occurred within the given timeout)

pollEvent(timeout_ms)

Poll a single Event.

An event are one or multiple changes that occurred in one single subscribed node. This is a low-level function to obtain a single event from the data server connection. To get all data waiting in the buffers, this command should be executed continuously until an empty dict is returned.

The poll() function is better suited in many cases, as it returns the data accumulated over some time period. Args: timeout_ms: Poll timeout in [ms]. Recommended value is 500ms.

Returns:

Type Description
Dict[str, LabOneResultAny]

A dict with the polled event. (Empty if no event occurred within the given timeout)

subscribe(path)

Subscribe to one or several nodes.

Fetch data with the poll command. In order to avoid fetching old data that is still in the buffer, execute a sync command before subscribing to data streams.

Parameters:

Name Type Description Default
path Union[str, List[str]]

Path string of the node. Use wild card to select all. Alternatively also a list of path strings can be specified.

required

unsubscribe(path)

Unsubscribe data streams.

Use this command after recording to avoid buffer overflows that may increase the latency of other command.

Parameters:

Name Type Description Default
path Union[str, List[str]]

Path string of the node. Use wild card to select all. Alternatively also a list of path strings can be specified.

required