Skip to content

Register the loop state on Python operators before process_state #8641

Description

@aglinxinyuan

Feature Summary

Inside a control block (LoopStart/LoopEnd), the iteration's loop variables reach every operator as a state message. A Python operator sees that message only as the argument of process_state, so any other callback, such as process_tuple, has no way to read the current iteration's variables unless the author stores them by hand.

Proposed Solution or Design

Register the state on the operator before the callback runs, the same for every Python operator:

  1. Operator gains a state attribute, None until a state message arrives. LoopStart and LoopEnd, which kept their own loop variables in self.state, keep them in self.variables instead.
  2. The Python worker sets operator.state right before it calls process_state. That covers DataProcessor.process_state and the LoopEnd's deferred consume in the main loop, which calls the operator directly.
  3. The default process_state is unchanged and still forwards the state downstream.

This is the Python counterpart of the JVM registration in #8635, split into its own change.

Affected Area

Workflow Engine (Amber)

Activity

  1. added a commit that references this issue on Nov 10, 2026
    4fba9eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions