Repository navigation
#266 - Allow to stop a running process with stop checkers - #267
Merged
Merged
Conversation
Services implementing the new ProcessStopCheckerInterface (autoconfigured, tag cleverage_process.stop_checker, new optional $stopCheckers argument of ProcessManager) are asked before each task execution; when one of them returns true, the task is not executed and the process fails with a ProcessFailedException whose previous exception is the new ProcessStoppedException. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #266: a running process can be stopped from the outside (first step of cleverage/ui-process-bundle#143, the "Stop" action of the UI).
Changes
CleverAge\ProcessBundle\Model\ProcessStopCheckerInterface(shouldStop(ProcessState $state): bool). Implementations are autoconfigured (tagcleverage_process.stop_checker) and injected intoProcessManager(new optionaliterable $stopCheckers = []argument,!tagged_iteratorinmanager.yaml).ProcessManager::processExecution()asks the checkers before each task execution (process, proceed, flush; once per item for the iterable tasks). When one of them returnstrue, the task is not executed and its state is stopped with the newCleverAge\ProcessBundle\Exception\ProcessStoppedException: the process fails as with thestoperror strategy, whatever the taskerror_strategy(askipstrategy or error outputs do not swallow the stop). It throws aProcessFailedExceptionwhose previous exception is theProcessStoppedException, andcleverage_process.failis dispatched.Note (differs from the issue description): as for any failure (task error with the
stopstrategy), the remaining items are not flushed and the tasks are not finalized:doExecute()leaves on the exception. Kept consistent on purpose; running flush / finalize on failure would be a broader change.Documentation
docs/04-advanced_workflow.md: new "Stopping a running process" section (behaviour, throttled checker example, limits: long blocking calls,ProcessLauncherTask/ProcessExecutorTasksub-processes, recognizing a stop in the chain of previous exceptions).Tests
ProcessManagerStopCheckerTest(realProcessManager,ConstantIterableOutputTask+ recording task): without checker all items run; a checker returningfalseis called before each task / item; a stop on the 3rd item processes only 1 and 2, ignores theskipstrategy and the error output,ProcessFailedExceptionwith theProcessStoppedExceptionas previous, failed event and history; any checker can request the stop.CleverAgeProcessExtensionTest: autoconfiguration tag and tagged iterator argument of the process manager.Requirements
Breaking changes
None: new interface, new exception, new optional constructor argument; no behaviour change without checker. Minor.
🤖 Generated with Claude Code