1.7.2. Connector base classes

This section contains documentation of the base classes of the connector classes.

class connectors.connectors.Connector(instance, method, parallelization, executor)

Base class for connectors. Connectors are objects that replace methods of a class so that they can be connected to each other. This way changing data at one end of a connection chain will automatically cause the data at the other end of the chain to be updated, when that data is retrieved the next time.

Parameters:
connect(connector)

Abstract method that defines the interface of a Connector for connecting it with other connectors.

Parameters:connector – the Connector instance to which this connector shall be connected
Returns:the instance of which this Connector has replaced a method
disconnect(connector)

Abstract method that defines the interface of a Connector for disconnecting it from a connector, to which it is currently connected.

Parameters:connector – a Connector instance from which this connector shall be disconnected
Returns:the instance of which this Connector has replaced a method
set_executor(executor)

Sets the executor, which handles the computations, when the data is retrieved through this connector. An executor can be created with the connectors.executor() function. It manages the order and the parallelization of the computations, when updating the data in a processing chain. If multiple connectors in a processing chain need to be computed, the executor of the connector, which started the computations, is used for all computations.

Parameters:executor – an Executor instance, that can be created with the connectors.executor() function
set_parallelization(parallelization)

Specifies, if and how the execution of this connector can be parallelized. The choices are no parallelization, the execution in a separate thread and the execution in a separate process. This method specifies a hint, which level of parallelization is possible with the connector. If the executor of the connector, through which the computation is started, does not support the specified level, the next simpler one will be chosen. E.g. if a connector can be parallelized in a separate process, but the executor only allows threads or sequential execution, the connector will be executed in a separate thread.

Parameters:parallelization – a flag from the connectors.Parallelization enum
class connectors._connectors._baseclasses.InputConnector(instance, method, laziness, parallelization, executor)

Base class for input connectors, that replace setter methods.

Parameters:
connect(connector)

Connects this InputConnector to an output.

Parameters:connector – the Connector instance to which this connector shall be connected
Returns:the instance of which this InputConnector has replaced a method
disconnect(connector)

Disconnects this InputConnector from an output, to which is has been connected.

Parameters:connector – a Connector instance from which this connector shall be disconnected
Returns:the instance of which this Connector has replaced a method
set_executor(executor)

Sets the executor, which handles the computations, when the data is retrieved through this connector. An executor can be created with the connectors.executor() function. It manages the order and the parallelization of the computations, when updating the data in a processing chain. If multiple connectors in a processing chain need to be computed, the executor of the connector, which started the computations, is used for all computations.

Parameters:executor – an Executor instance, that can be created with the connectors.executor() function
set_laziness(laziness)

Configures the lazy execution of the connector. Normally the connectors are executed lazily, which means, that any computation is only started, when the result of a processing chain is requested. For certain use cases it is necessary to disable this lazy execution, though, so that the values are updated immediately as soon as new data is available. There are different behaviors for the (non) lazy execution, which are described in the connectors.Laziness enum.

Parameters:laziness – a flag from the connectors.Laziness enum
set_parallelization(parallelization)

Specifies, if and how the execution of this connector can be parallelized. The choices are no parallelization, the execution in a separate thread and the execution in a separate process. This method specifies a hint, which level of parallelization is possible with the connector. If the executor of the connector, through which the computation is started, does not support the specified level, the next simpler one will be chosen. E.g. if a connector can be parallelized in a separate process, but the executor only allows threads or sequential execution, the connector will be executed in a separate thread.

Parameters:parallelization – a flag from the connectors.Parallelization enum