Skip to content

Preserve DataLoader batch completion after a request is cancelled - #1608

Open
FanWu-ai wants to merge 1 commit into
graphql-python:masterfrom
FanWu-ai:fix-cancelled-dataloader-futures-20261011
Open

FanWu-ai wants to merge 1 commit into
graphql-python:masterfrom
FanWu-ai:fix-cancelled-dataloader-futures-20261011

Conversation

@FanWu-ai

Copy link
Copy Markdown

Cancelling one DataLoader.load() future currently raises InvalidStateError when the batch finishes. The failure handler then attempts to write to that same cancelled future, so other requests in the batch can remain unresolved indefinitely.

Skip already-completed futures when assigning individual results or exceptions. On whole-batch failure, retain cache invalidation for every key while rejecting only pending futures.

Regression tests cover cancellation at the beginning, middle, and end of successful and failed batches, plus a real scheduled batch cancelled while its resolver is awaiting. The surviving result and its cached value remain available.

Validation on Python 3.10.22/Linux:

  • Pristine complete suite: 465 passed, including benchmarks, with no skips.
  • Six original regression failures; final complete suite: 472 passed, no skips, 96% coverage.
  • Configured Mypy and every applicable pinned pre-commit hook pass.
  • Wheel/sdist builds, strict Twine metadata validation and whitespace checks pass; packaged module bytes match tested source.
  • Independent checks also preserve already-resolved values and per-item error handling.

The existing test deprecation and setuptools universal-wheel warnings remain. Other Python versions and hosted CI have not run locally.

AI assistance: OpenAI Codex was used to investigate, implement and test this fix. No human review is claimed.

AI assistance: OpenAI Codex was used for investigation, implementation, regression tests, and automated validation.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 17:11

This branch has not been deployed

No deployments
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.

1 participant