1.7.4. Proxy classes¶
This section contains the documentation of the connector proxy classes. The proxies emulate the behavior of the connectors and are used to avoid circular references. See the decorators on how to create connectors and the connectors themselves on how to use and configure them.
1.7.4.1. Base class¶
-
class
connectors._proxies._baseclasses.
ConnectorProxy
(instance, method, parallelization, executor)¶ A base class for proxy objects of connectors. Connector proxies are returned by the connector decorators, while the methods are replaced by the actual connectors. Think of a connector proxy like of a bound method, which is also created freshly, whenever a method is accessed. The actual connector only has a weak reference to its instance, while this proxy has a hard reference, but mimics the connector in almost every other way. This makes constructions like
value = Class().connector()
possible. Without the proxy, the instance of the class would be deleted before the connector method is called, so that the weak reference of the connector would be expired during its call.Parameters: - instance – the instance in which the method is replaced by this connector proxy
- method – the unbound method that is replaced by this connector proxy
- parallelization – a flag from the
connectors.Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theset_executor()
method for details
-
connect
(connector)¶ Connects this connector with another one.
Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: 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 theconnectors.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
1.7.4.2. Proxy classes¶
-
class
connectors._proxies.
OutputProxy
(instance, method, caching, parallelization, executor)¶ A proxy class for output connectors. Connector proxies are returned by the connector decorators, while the methods are replaced by the actual connectors. Think of a connector proxy like of a bound method, which is also created freshly, whenever a method is accessed. The actual connector only has a weak reference to its instance, while this proxy has a hard reference, but mimics the connector in almost every other way. This makes constructions like
value = Class().connector()
possible. Without the proxy, the instance of the class would be deleted before the connector method is called, so that the weak reference of the connector would be expired during its call.Parameters: - instance – the instance in which the method is replaced by this connector proxy
- method – the unbound method that is replaced by this connector proxy
- caching – True, if caching shall be enabled, False otherwise. See
the
set_caching()
method for details - parallelization – a flag from the
connectors.Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theOutputConnector
’sset_executor()
method for details
-
connect
(connector)¶ Connects this connector with another one.
Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: the instance of which this Connector
has replaced a method
-
set_caching
(caching)¶ Specifies, if the result value of this output connector shall be cached. If caching is enabled and the result value is retrieved (e.g. through a connection or by calling the connector), the cached value is returned and the replaced getter method is not called unless the result value has to be re-computed, because an observed setter method has changed a parameter for the computation. In this case, the getter method is only called once, independent of the number of connections through which the result value has to be passed.
Parameters: caching – True, if caching shall be enabled, False otherwise
-
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 theconnectors.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._proxies.
SingleInputProxy
(instance, method, observers, announce_condition, notify_condition, laziness, parallelization, executor)¶ A proxy class for input connectors. Connector proxies are returned by the connector decorators, while the methods are replaced by the actual connectors. Think of a connector proxy like of a bound method, which is also created freshly, whenever a method is accessed. The actual connector only has a weak reference to its instance, while this proxy has a hard reference, but mimics the connector in almost every other way. This makes constructions like
value = Class().connector()
possible. Without the proxy, the instance of the class would be deleted before the connector method is called, so that the weak reference of the connector would be expired during its call.Parameters: - instance – the instance in which the method is replaced by this connector proxy
- method – the unbound method that is replaced by this connector proxy
- observers – the names of output methods that are affected by passing a value to this connector proxy
- announce_condition – a method, that defines the condition for the
announcements to the observing output connectors.
This method must not require any arguments apart
from
self
- notify_condition – a method, that defines the condition for the
notifications to the observing output connectors.
This method must accept the new input value as
an argument in addition to
self
- laziness – a flag from the
connectors.Laziness
enum. See theset_laziness()
method for details - parallelization – a flag from the
connectors.Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theSingleInputConnector
’sset_executor()
method for details
-
connect
(connector)¶ Connects this connector with another one.
Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: 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 theconnectors.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
-
class
connectors._proxies.
MultiInputProxy
(instance, method, remove_method, replace_method, observers, announce_condition, notify_condition, laziness, parallelization, executor)¶ A proxy class for multi-input connectors. Connector proxies are returned by the connector decorators, while the methods are replaced by the actual connectors. Think of a connector proxy like of a bound method, which is also created freshly, whenever a method is accessed. The actual connector only has a weak reference to its instance, while this proxy has a hard reference, but mimics the connector in almost every other way. This makes constructions like
value = Class().connector()
possible. Without the proxy, the instance of the class would be deleted before the connector method is called, so that the weak reference of the connector would be expired during its call.Parameters: - instance – the instance in which the method is replaced by this connector proxy
- method – the unbound method, that is replaced by this connector proxy
- remove_method – an unbound method, that is used to remove data, that has been added through this connector proxy
- replace_method – an unbound method, that is used to replace data, that has been added through this connector proxy
- observers – the names of output methods that are affected by passing a value to this connector proxy
- announce_condition – a method, that defines the condition for the
announcements to the observing output connectors.
This method must accept the data ID of the changed
output connector as an argument in addition to
self
- notify_condition – a method, that defines the condition for the
notifications to the observing output connectors.
This method must accept the data ID and the new
input value as an argument in addition to
self
- laziness – a flag from the
connectors.Laziness
enum. See theset_laziness()
method for details - parallelization – a flag from the
connectors.Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theMultiInputConnector
’sset_executor()
method for details
-
connect
(connector)¶ Connects this connector with another one.
Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: 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 theconnectors.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