SignalManager (signalmanager
)
A SignalManager instance handles the runtime signal propagation between widgets in a scheme workflow.
- class orangecanvas.scheme.signalmanager.SignalManager(parent: QObject | None = None, *, max_running: int | None = None, **kwargs: Any)[source]
Bases:
QObject
SignalManager handles the runtime signal propagation for a
Scheme
instance.Note
If a scheme instance is passed as a parent to the constructor it is also set as the workflow model.
- stateChanged(State)
Emitted when the state of the signal manager changes.
- updatesPending
Emitted when signals are added to the queue.
- processingStarted(SchemeNode)
Emitted right before a SchemeNode instance has its inputs updated.
- processingFinished(SchemeNode)
Emitted right after a SchemeNode instance has had its inputs updated.
- runtimeStateChanged(RuntimeState)
Emitted when SignalManager’s runtime state changes.
- class State(value)[source]
Bases:
IntEnum
SignalManager state flags.
See also
- Running = 0
The manager is running, i.e. it propagates signals
- Stopped = 1
The manager is stopped. It does not track node output changes, and does not deliver signals to dependent nodes
- Paused = 2
The manager is paused. It still tracks node output changes, but does not deliver new signals to dependent nodes. The pending signals will be delivered once it enters Running state again
- Running = 0
The manager is running, i.e. it propagates signals
- Stopped = 1
The manager is stopped. It does not track node ouput changes, and does not deliver signals to dependent nodes
- Paused = 2
The manager is paused. It still tracks node output changes, but does not deliver new signals to dependent nodes. The pending signals will be delivered once it enters Running state again
- class RuntimeState(value)[source]
Bases:
IntEnum
SignalManager runtime state.
See also
- Waiting = 0
Waiting, idle state. The signal queue is empty
- Processing = 1
…
- finished
Emitted when the execution finishes (there are no more nodes that need to run). Note: the nodes can activate again due to user interaction or other scheduled events, i.e. finished is not a definitive state. Use at your own discretion.
- started
Emitted when starting initial execution and when resuming after already emitting finished.
- start() None [source]
Start the update loop.
Note
The updates will not happen until the control reaches the Qt event loop.
- stop() None [source]
Stop the update loop.
Note
If the SignalManager is currently in process_queues it will still update all current pending signals, but will not re-enter until start() is called again.
- step() None [source]
Deliver signals to a single node (only applicable while the state() is Paused).
- runtime_state() RuntimeState [source]
Return the runtime state. This can be SignalManager.Waiting or SignalManager.Processing.
- signals_on_link(link: SchemeLink) List[Signal] [source]
Return
Signal
instances representing the current values present on the link.
- send(node: SchemeNode, channel: OutputSignal, value: Any, *args: Any, **kwargs: Any) None [source]
Send the value on the output channel from node.
Schedule the signal delivery to all dependent nodes
- Parameters:
node (SchemeNode) – The originating node.
channel (OutputSignal) – The nodes output on which the value is sent.
value (Any) – The value to send,
id (Any) –
Signal id.
Deprecated since version 0.1.19.
- invalidate(node: SchemeNode, channel: OutputSignal) None [source]
Invalidate the channel on node.
The channel is effectively considered changed but unavailable until a new value is sent via send. While this state is set the dependent nodes will not be updated.
All links originating with this node/channel will be marked with SchemeLink.Invalidated flag until a new value is sent with send.
- Parameters:
node (SchemeNode) – The originating node.
channel (OutputSignal) – The channel to invalidate.
Added in version 0.1.8.
- purge_link(link: SchemeLink) None [source]
Purge the link (send None for all ids currently present)
Deprecated since version 0.1.19.
- process_queued(max_nodes: Any | None = None) None [source]
Process queued signals.
Take the first eligible node from the pending input queue and deliver all scheduled signals.
- process_next() bool [source]
Process queued signals.
Take the first eligible node from the pending input queue and deliver all scheduled signals for it and return True.
If no node is eligible for update do nothing and return False.
- process_node(node: SchemeNode) None [source]
Process pending input signals for node.
- compress_signals(signals: List[Signal]) List[Signal] [source]
Compress a list of
Signal
instances to be delivered.Before the signal values are delivered to the sink node they can be optionally compressed, i.e. values can be merged or dropped depending on the execution semantics.
The input list is in the order that the signals were enqueued.
The base implementation returns the list unmodified.
- send_to_node(node: SchemeNode, signals: List[Signal]) None [source]
Abstract. Reimplement in subclass.
Send/notify the node instance (or whatever object/instance it is a representation of) that it has new inputs as represented by the signals list).
- Parameters:
node (SchemeNode)
signals (List[Signal])
- is_pending(node: SchemeNode) bool [source]
Is node (class:SchemeNode) scheduled for processing (i.e. it has incoming pending signals).
- Parameters:
node (SchemeNode)
- Returns:
pending
- Return type:
- pending_nodes() List[SchemeNode] [source]
Return a list of pending nodes.
The nodes are returned in the order they were enqueued for signal delivery.
- Returns:
nodes
- Return type:
List[SchemeNode]
- pending_input_signals(node: SchemeNode) List[Signal] [source]
Return a list of pending input signals for node.
- remove_pending_signals(node: SchemeNode) None [source]
Remove pending signals for node.
- blocking_nodes() List[SchemeNode] [source]
Return a list of nodes in a blocking state.
- invalidated_nodes() List[SchemeNode] [source]
Return a list of invalidated nodes.
Added in version 0.1.8.
- active_nodes() List[SchemeNode] [source]
Return a list of active nodes.
Added in version 0.1.8.
- is_blocking(node: SchemeNode) bool [source]
Is the node in blocking state.
Is it currently in a state where will produce new outputs and therefore no signals should be delivered to dependent nodes until it does so. Also no signals will be delivered to the node until it exits this state.
The default implementation returns False.
Deprecated since version 0.1.8: Use a combination of is_invalidated and is_ready.
- is_ready(node: SchemeNode) bool [source]
Is the node in a state where it can receive inputs.
Re-implement this method in as subclass to prevent specific nodes from being considered for input update (e.g. they are still initializing runtime resources, executing a non-interruptable task, …)
Note that whenever the implicit state changes the post_update_request should be called.
The default implementation returns the state of the node’s SchemeNode.NotReady flag.
- Parameters:
node (SchemeNode)
- is_invalidated(node: SchemeNode) bool [source]
Is the node marked as invalidated.
- Parameters:
node (SchemeNode)
- Returns:
state
- Return type:
- has_invalidated_outputs(node: SchemeNode) bool [source]
Does node have any explicitly invalidated outputs.
- Parameters:
node (SchemeNode)
- Returns:
state
- Return type:
See also
Added in version 0.1.8.
- has_invalidated_inputs(node: SchemeNode) bool [source]
Does the node have any immediate ancestor with invalidated outputs.
- Parameters:
node (SchemeNode)
- Returns:
state
- Return type:
Note
The node’s ancestors are only computed over enabled links.
Added in version 0.1.8.
- is_active(node: SchemeNode) bool [source]
Is the node considered active (executing a task).
- Parameters:
node (SchemeNode)
- Returns:
active
- Return type:
- node_update_front() Sequence[SchemeNode] [source]
Return a list of nodes on the update front, i.e. nodes scheduled for an update that have no ancestor which is either itself scheduled for update or is in a blocking state).
Note
The node’s ancestors are only computed over enabled links.
- post_update_request()[source]
Schedule an update pass.
Call this method whenever:
a node’s outputs change (note that this is already done by send)
any change in the node that influences its eligibility to be picked for an input update (is_ready, is_blocking …).
Multiple update requests are merged into one.
- class orangecanvas.scheme.signalmanager.Signal(link: SchemeLink, value: Any, id: Any | None = None, index: int = -1)[source]
A signal sent via a link between two nodes.
- link
The link on which the signal is sent
- Type:
- value
The signal value
- Type:
Any
- id
Deprecated since version 0.1.19.
- Type:
Any
- index
Position of the link in sink_node’s input links at the time the signal is enqueued or -1 if not applicable.
- Type:
See also
InputSignal.flags
,OutputSignal.flags
- property channel: InputSignal
Alias for self.link.sink_channel