SignalManager (signalmanager)

A SignalManager instance handles the runtime signal propagation between widgets in a scheme workflow.

class orangecanvas.scheme.signalmanager.SignalManager(parent=None, *, max_running=None, **kwargs)[source]

Bases: PyQt5.QtCore.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: enum.IntEnum

SignalManager state flags.

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: enum.IntEnum

SignalManager runtime state.

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.

workflow()[source]

Return the Scheme instance.

scheme()

Alias

set_workflow(workflow)[source]

Set the workflow model.

Parameters

workflow (Scheme) –

has_pending()[source]

Does the manager have any signals to deliver?

start()[source]

Start the update loop.

Note

The updates will not happen until the control reaches the Qt event loop.

stop()[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.

pause()[source]

Pause the delivery of signals.

resume()[source]

Resume the delivery of signals.

step()[source]

Deliver signals to a single node (only applicable while the state() is Paused).

state()[source]

Return the current state.

Returns

state

Return type

SignalManager.State

runtime_state()[source]

Return the runtime state. This can be SignalManager.Waiting or SignalManager.Processing.

eventFilter(self, QObject, QEvent) bool[source]

Return Signal instances representing the current values present on the link.

Return the contents on the link.

send(node, channel, value, *args, **kwargs)[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, channel)[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

New in version 0.1.8.

Purge the link (send None for all ids currently present)

Deprecated since version 0.1.19.

process_queued(max_nodes=None)[source]

Process queued signals.

Take the first eligible node from the pending input queue and deliver all scheduled signals.

process_next()[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)[source]

Process pending input signals for node.

compress_signals(signals)[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.

Parameters

signals (List[Signal]) –

Returns

signals

Return type

List[Signal]

send_to_node(node, signals)[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
is_pending(node)[source]

Is node (class:SchemeNode) scheduled for processing (i.e. it has incoming pending signals).

Parameters

node (SchemeNode) –

Returns

pending

Return type

bool

pending_nodes()[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)[source]

Return a list of pending input signals for node.

remove_pending_signals(node)[source]

Remove pending signals for node.

blocking_nodes()[source]

Return a list of nodes in a blocking state.

invalidated_nodes()[source]

Return a list of invalidated nodes.

New in version 0.1.8.

active_nodes()[source]

Return a list of active nodes.

New in version 0.1.8.

is_blocking(node)[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: orangecanvas.scheme.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: orangecanvas.scheme.node.SchemeNode) bool[source]

Is the node marked as invalidated.

Parameters

node (SchemeNode) –

Returns

state

Return type

bool

has_invalidated_outputs(node)[source]

Does node have any explicitly invalidated outputs.

Parameters

node (SchemeNode) –

Returns

state

Return type

bool

See also

invalidate

New in version 0.1.8.

has_invalidated_inputs(node)[source]

Does the node have any immediate ancestor with invalidated outputs.

Parameters

node (SchemeNode) –

Returns

state

Return type

bool

Note

The node’s ancestors are only computed over enabled links.

New in version 0.1.8.

is_active(node)[source]

Is the node considered active (executing a task).

Parameters

node (SchemeNode) –

Returns

active

Return type

bool

node_update_front()[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: orangecanvas.scheme.link.SchemeLink, value: Any, id: Optional[Any] = None, index: int = - 1)[source]

A signal sent via a link between two nodes.

The link on which the signal is sent

Type

SchemeLink

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

int

See also

InputSignal.flags, OutputSignal.flags

class Close(link: orangecanvas.scheme.link.SchemeLink, value: Any, id: Optional[Any] = None, index: int = - 1)
class New(link: orangecanvas.scheme.link.SchemeLink, value: Any, id: Optional[Any] = None, index: int = - 1)
class Update(link: orangecanvas.scheme.link.SchemeLink, value: Any, id: Optional[Any] = None, index: int = - 1)
property channel: orangecanvas.registry.description.InputSignal

Alias for self.link.sink_channel