Class Subscription

class sila2.client.Subscription

Subscription to a stream of items provided by a SiLA Server

add_callback(func: Callable[[ItemType], Any]) None

Add a function to be called on every value update. Can only be used while this subscription is not cancelled.


func – Function to be called on every value update. It will be called with the new value as positional parameter: func(new_value)


RuntimeError – If this subscription was cancelled


Can be used as a context manager:

with thing.subscribe() as subscription:
# subscription is cancelled here
clear_callbacks() None

Deregister all currently registered callback functions

property callbacks: Tuple[Callable[[ItemType], Any], ...]

All currently registered callback functions

abstract cancel() None

Cancel this subscription

abstract property is_cancelled: bool

True is this subscription was cancelled