Commits
Click on a commit to change the comparison rangeAdd worker-side cancellation for pending flow runs
Implement optional cancellation handling in workers for flow runs that
are cancelled while still in PENDING state (before the runner starts).
- Add PREFECT_WORKER_ENABLE_CANCELLATION setting (disabled by default)
- Add PREFECT_WORKER_CANCELLATION_POLL_SECONDS setting (default 120s)
- Subscribe to cancellation events via WebSocket for real-time detection
- Fall back to polling if WebSocket connection fails
- Poll for cancelling flow runs once on worker startup
- Add kill_infrastructure() method to BaseWorker (raises NotImplementedError)
- Implement kill_infrastructure() in KubernetesWorker to delete jobs
- Only handle cancellation for flow runs with start_time=None (pending)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>2 days ago
by joshuastagner Merge branch 'main' into optional-worker-pending-run-cancellation2 days ago
by joshuastagner Refactor worker cancellation to use FlowRunCancellingObserver
Simplify worker-side cancellation handling by reusing the existing
FlowRunCancellingObserver from the runner instead of implementing
custom WebSocket subscription and polling logic.
- Use FlowRunCancellingObserver for cancellation detection
- Register/unregister flow run IDs with observer on submit/complete
- Use lambda callback pattern consistent with runner implementation
- Remove custom cancellation event handling code
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>14 hours ago
by joshuastagner Make configuration required in KubernetesWorker.kill_infrastructure
The base worker now always provides configuration when calling
kill_infrastructure, so the Optional type and None check are no
longer needed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>14 hours ago
by joshuastagner Filter worker cancellation events by work pool ID
Use EventAnyResourceFilter to filter cancellation events so workers
only receive events for flow runs in their specific work pool. This
uses the any_resource filter which has proper in-memory filtering
support for WebSocket event streams.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>11 hours ago
by joshuastagner