Repository navigation
fix: The form in the loop body will not pause the outer layer - #8222
Conversation
|
|
||
| if wf_manage.signal == Signal.CONTINUE: | ||
| self._run_next() | ||
| return |
There was a problem hiding this comment.
Here's my review of the diff:
Issues / Observations
1. Behavior change may break existing callers
Previously, Signal.BREAK and Signal.FORM were handled identically (complete with Status.SUCCESS). Now FORM completes with an extra signal=Signal.FORM argument. Check that self.complete() actually accepts a signal keyword — if not defined or if it doesn't propagate the signal upstream correctly, this will raise TypeError or silently drop the signal. Confirm the signature and downstream handling of the propagated signal.
2. Duplicated run_time computation
The line:
self.data["run_time"] = time.time() - self.data.get("start_time", time.time())is now duplicated in both branches. Consider factoring it out before the branch, or into a small helper, to reduce drift risk.
3. Signal.FORM propagation must be handled by parent
The comment says "propagate interrupt upward, pause parent workflow, resume at position after user submit." Verify:
- The parent
on_completehandler actually inspects the child's returnedsignal(e.g.,wf_manage.result.signalor wherevercomplete(..., signal=...)stores it). - There is logic to persist the current
positionso resumption works. If no such resume mechanism exists yet, the new behavior will complete the loop body but not actually pause/resume — it could silently end the loop iteration instead.
4. Status.SUCCESS for a "paused/awaiting form" state is semantically questionable
Completing with Status.SUCCESS while emitting Signal.FORM conflates "finished successfully" with "interrupted awaiting input." Consider a distinct status (e.g., Status.PAUSED / Status.AWAITING_FORM) to make the state explicit and avoid mistaking it for a normal completion in metrics/logging.
5. Idempotency / repeated submission
If the parent re-invokes the loop body after form submission, ensure start_time and run_time are not double-counted (run_time is rewritten each time — likely fine, but confirm start_time isn't reset on resume).
6. Missing test coverage note
This is a control-flow change for interruptions. Ensure tests cover: BREAK path unchanged, FORM path sets the propagated signal, and the parent resumes via position.
7. Minor: readability
An elif chain would read more clearly than sequential if ... return blocks when all conditions are mutually exclusive signals:
if wf_manage.signal == Signal.BREAK:
...
elif wf_manage.signal == Signal.FORM:
...
elif wf_manage.signal == Signal.CONTINUE:
...Summary
Main risks: (a) complete(signal=...) must exist and be consumed by the parent; (b) the resume-at-position machinery must actually exist, otherwise FORM interruption won't work as intended; (c) using SUCCESS for a paused state is misleading. Validate these before merging.
fix: The form in the loop body will not pause the outer layer