sub

class cyclonedds.sub.Subscriber(domain_participant, qos=None, listener=None)[source]

Bases: cyclonedds.core.Entity

Parameters
notify_readers()[source]
class cyclonedds.sub.DataReader(subscriber_or_participant, topic, qos=None, listener=None)[source]

Bases: cyclonedds.core.Entity, Generic[cyclonedds.sub._T]

Subscribe to a topic and read/take the data published to it.

All returned samples are annotated with the sample.sample_info attribute.

Parameters
property topic: cyclonedds.topic.Topic[cyclonedds.sub._T]
read(N=1, condition=None, instance_handle=None)[source]

Read a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.

Reading samples does not remove them from the DataReader's receive queue. So read methods may return the same sample in multiple calls.

Parameters
Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type

List[cyclonedds.sub._T]

take(N=1, condition=None, instance_handle=None)[source]

Take a maximum of N samples, non-blocking. Optionally use a read/query-condition to select which samples you are interested in.

Taking samples removes them from the DataReader's receive queue. So take methods will not return the same sample more than once.

Parameters
Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type

List[cyclonedds.sub._T]

read_next()[source]

Shortcut method to read exactly one sample or return None.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type

Optional[cyclonedds.sub._T]

take_next()[source]

Shortcut method to take exactly one sample or return None.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Return type

Optional[cyclonedds.sub._T]

read_iter(condition=None, timeout=None)[source]

Shortcut method to iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters

timeout (Optional[int]) –

Return type

Generator[cyclonedds.sub._T, None, None]

read_one(condition=None, timeout=None)[source]

Shortcut method to block and take exactly one sample or raise a timeout

Parameters

timeout (Optional[int]) –

Return type

cyclonedds.sub._T

take_iter(condition=None, timeout=None)[source]

Shortcut method to iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters

timeout (Optional[int]) –

Return type

Generator[cyclonedds.sub._T, None, None]

take_one(condition=None, timeout=None)[source]

Shortcut method to block and take exactly one sample or raise a timeout

Parameters

timeout (Optional[int]) –

Return type

cyclonedds.sub._T

async read_aiter(condition=None, timeout=None)[source]

Shortcut method to async iterate reading samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters

timeout (Optional[int]) –

Return type

AsyncGenerator[cyclonedds.sub._T, None]

async take_aiter(condition=None, timeout=None)[source]

Shortcut method to async iterate taking samples. Iteration will stop once the timeout you supply expires. Every time a sample is received the timeout is reset.

Raises

DDSException – If any error code is returned by the DDS API it is converted into an exception.

Parameters

timeout (Optional[int]) –

Return type

AsyncGenerator[cyclonedds.sub._T, None]

wait_for_historical_data(timeout)[source]
Parameters

timeout (int) –

Return type

bool

lookup_instance(sample)[source]
Parameters

sample (cyclonedds.sub._T) –

Return type

Optional[int]