Skip to content

Settle owned execution tasks when consumers are cancelled - #323

Open
AryanRG wants to merge 1 commit into
graphql-python:mainfrom
AryanRG:fix/cancel-abort-signal-owned-tasks
Open

AryanRG wants to merge 1 commit into
graphql-python:mainfrom
AryanRG:fix/cancel-abort-signal-owned-tasks

Conversation

@AryanRG

@AryanRG AryanRG commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #322.

Cancelling a query, subscription consumer or incremental-results consumer can leave owned work unsettled when an idle AbortSignal is supplied.

The two executor wrappers now cancel and await their task before re-raising CancelledError. The incremental publisher also settles its pending batch task and abort waiter, consuming the batch task's cancellation or StopAsyncIteration.

The work queue retains a cancelled computation's pending future until cleanup settles. This is needed for deferred resolvers with early execution disabled, because abort clears the computation's stored future before the queue can await it.

Cancellation now waits for deferred resolver cleanup, including without a signal. A resolver that ignores cancellation can therefore delay completion, as with a native task.

The regressions cover query and subscription cancellation plus incremental consumer timeout with early execution disabled and enabled. All four cases fail on unchanged main. The incremental test checks asynchronous cleanup and unhandled loop errors.

Validation covers the following.

  • Python 3.14.4 full suite — 3,830 passed, 18 skipped, 100% configured source/test coverage.
  • Python 3.10.22 full suite — 3,831 passed, 17 skipped.
  • Full Ruff, formatting and mypy pass.
  • Public probes cover both early-execution settings, supplied tasks and explicit abort reasons on both interpreters.

Default skips, opt-in slow tests and the full platform/interpreter matrix remain unverified.

@codspeed

codspeed Bot commented Nov 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing AryanRG:fix/cancel-abort-signal-owned-tasks (7e23241) with main (2bd2557)

Open in CodSpeed

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.

Cancelling a subscription consumer leaves its source running with an AbortSignal

1 participant