Conversation
….com/microsoft/durabletask-python into andystaples/abandon-failed-workitems
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces cancellation functionality to the async worker manager system, enabling graceful handling of failed work items and proper cleanup during shutdowns.
Key Changes:
- Adds cancel methods (
_cancel_orchestrator,_cancel_activity,_cancel_entity_batch) that invoke appropriate abandon operations when work items cannot be completed - Updates all submit methods to accept cancellation functions alongside execution functions
- Implements error handling in the
run()method to cancel pending work items when the worker manager encounters exceptions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| durabletask/worker.py | Adds cancellation methods, updates submit signatures to accept cancel functions, adds error handling for queue exceptions, and implements cancellation during reset operations |
| tests/durabletask/test_worker_concurrency_loop_async.py | Updates test to provide cancel function stubs when submitting work items to match the new API |
| tests/durabletask/test_worker_concurrency_loop.py | Updates test to provide cancel function stubs when submitting work items to match the new API |
Comments suppressed due to low confidence (3)
tests/durabletask/test_worker_concurrency_loop.py:131
- Call to method _AsyncWorkerManager.submit_orchestration with too few arguments; should be no fewer than 2.
manager.submit_orchestration(make_work("orch", i))
tests/durabletask/test_worker_concurrency_loop.py:132
- Call to method _AsyncWorkerManager.submit_activity with too few arguments; should be no fewer than 2.
manager.submit_activity(make_work("act", i))
durabletask/worker.py:2228
- 'except' clause does nothing but pass and there is no explanatory comment.
except Exception:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
berndverst
approved these changes
Nov 11, 2025
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.
In certain cases, when a workitem fails in the SDK due to an internal error, or a worker shutdown, we need to send an abandon message to the backend to let it know that the items need to be re-sent for processing - without this, they may become stuck.
Adds support for abandoning workitems in these cases.