Repository navigation
fix: cancellation propagates from run_maintenance_safe - #110
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
run_maintenance_safe caught CancelledError, KeyboardInterrupt and SystemExit and returned them on result.error, so asyncio.timeout() never fired, a cancelled task did not end cancelled, and Ctrl+C in the sync mirror was swallowed. They now propagate from both mirrors; every Exception still lands on result.error. The Redis lock stops a run whose lease it lost by cancelling it. It now takes that cancellation back and raises LockLostError, so a lost lease is still reported on the result; a cancellation from outside at the same time still propagates. Closes #107
AlexeyShalaev
force-pushed
the
fix/107-cancellation-propagates
branch
from
October 16, 2026 15:05
5a4b662 to
008457d
Compare
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.
Closes #107.
run_maintenance_safeno longer catchesasyncio.CancelledError,KeyboardInterruptorSystemExit(aio), norKeyboardInterruptorSystemExit(sync).run_maintenancelogs them before re-raising, as before. EveryExceptionstill goes toresult.error.CancelledError, callsuncancel(), and raises the newLockLostError(aPartitionError, exported frompg_partsmith) when its cancellation is the only one pending. So a lost lease still lands onresult.error. When the task was also cancelled from outside, theCancelledErrorpropagates. The sync lock never cancels its holder, so it doesn't change.docs/concepts/execution.md, the scheduling guide, the production page anddocs/agents.mdno longer say the safe variant "never raises". They now say that errors land on the result and that cancellation propagates.Tests:
asyncio.timeout(0.05)around a slow run raisesTimeoutError.task.cancel()leaves the task cancelled.CancelledError,KeyboardInterruptandSystemExitpropagate (both mirrors).LockLostError, and the task'scancelling()is back to 0.LockLostErroronresult.error.The tests that pinned the old swallowing were rewritten.
Results: unit 2876 passed, integration (PG 17) 575 passed, ruff and mypy clean, docs build clean.
Who notices: code that ran
run_maintenance_safeunder a timeout or a cancelling supervisor and relied on getting a result back. That is the behaviour #107 asks to fix, so this ships as a fix.