Skip to content

Conversation

@andystaples
Copy link
Contributor

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.

@andystaples andystaples marked this pull request as ready for review November 6, 2025 21:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

        manager.submit_orchestration(make_work("orch", i))

tests/durabletask/test_worker_concurrency_loop.py:132

        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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants