Static controls for named macro flows and copied messages between execution branches. Variables stay isolated; Flow.params supplies startup input and each invocation owns a FIFO message queue.
Syntax
Flow
This class cannot be constructed directly.
Returns
—
Example
# Save an enemy template and configure watch_enemy before running
# Main: arm the watcher and stop it after the main task
Flow.start("watch_enemy")
Flow.send("watch_enemy", {"command": "ARM"})
wait(1000)
Flow.stop("watch_enemy")
Read-only copied input for the current branch. The main flow receives an empty dict. Each read returns safe data detached from coordinator and parent-VM collections.
Methods
6 methods
Flow.start
Static Method
Start a configured named flow and return after admission, with its queue already registered. At most two background branches run beside main; background branches may start peers. Only one live invocation per name is allowed, including paused or stopping invocations. Invalid or duplicate names, capacity errors and branch errors stop the whole Run, as do System.stop() and Main Stop. Main completion joins live workers: explicitly stop long-lived workers. Params are copied with the same safe-value limits as Flow.send().
Optional safe copied input exposed as Flow.params in the started branch.
Optional · Positional or named
Default:None
Returns
Int — A positive, monotonically increasing branch instance number for dock status and logs; it is not a control handle.
Example
# Start recognition and telemetry beside the main flow
recognition_no = Flow.start("recognition", {"region": "arena", "threshold": 0.86})
telemetry_no = Flow.start("telemetry")
# Inside the configured recognition flow, read this branch's copied input
region_name = Flow.params.get("region", "full_screen")
threshold = Flow.params.get("threshold", 0.8)
Flow.send
Static Method
Enqueue a deep copy for the currently running named invocation without waiting. FIFO delivery is thread-safe, including while paused. Safe values are None, Boolean, finite numbers, String, list, tuple and dict with String keys; maximum depth is 8, total values 512 and total text length 65536. Callables, resource/domain objects and cycles are errors. Each invocation has a new queue; stop or completion discards pending messages.
Exact configured target flow name; there is no synthesized main name.
Required · Positional or named
No default
dataAny
Required safe value copied before enqueueing.
Required · Positional or named
No default
Returns
Boolean — True if accepted; False for an unknown, inactive or stopping target.
Example
# Send an ARM command to the configured watcher
Flow.start("watch_enemy")
accepted = Flow.send("watch_enemy", {"command": "ARM"})
print(accepted)
Flow.receive
Static Method
Remove the oldest message from the current execution branch queue, suspending without a busy loop until a message or timeout. Main and background branches can receive; nested named foreground groups use their owning branch queue. Cancellation wakes the wait promptly. Pause preserves queued messages. Received collections are detached copies.
Syntax
Flow.receive(timeout=None)
Parameters
Name
Description
timeoutNumber?
Optional finite timeout in milliseconds: 0 <= timeout < 2^63. Fractional milliseconds are truncated; None waits indefinitely, 0 checks immediately.
Optional · Positional or named
Default:None
Returns
Any? — The oldest detached payload, or None on timeout or when an immediate check finds an empty queue. A None payload has the same return value.
Example
# Configured watch_enemy flow: wait for ARM, then check commands between work
message = Flow.receive()
if message is not None and message.get("command") == "ARM":
while True:
command = Flow.poll()
if command is not None:
print(command)
if Region().find("enemy", timeout=0).found:
print("enemy")
wait(100)
Flow.poll
Static Method
Remove the oldest message from the current execution branch queue immediately. Uses the same queue and detached payload rules as Flow.receive().
Syntax
Flow.poll()
Returns
Any? — The oldest detached payload, or None when empty; a None payload also returns None.
Example
# Check for a command without waiting
message = Flow.poll()
if message is not None:
print(message)
Flow.running
Static Method
Check whether a named invocation is active, including while paused. The result may change immediately after the call.
Exact configured target flow name; there is no synthesized main name.
Required · Positional or named
No default
Returns
Boolean — True while active; False when unknown, stopping or completed.
Example
print(Flow.running("watch_enemy"))
Flow.stop
Static Method
Request cancellation of only the target background branch without waiting for cleanup. Main and peers keep running; main cannot be stopped with this API. A named foreground group owned by a background branch targets that owning branch. Self-stop terminates the calling branch. The name remains reserved until asynchronous cleanup completes, so do not immediately restart it. The dock still provides only Pause/Resume for background branches; Main Pause/Resume applies to all branches and global Resume clears local pause flags.