Skip to content

fix: preserve async query cancellation on Python 3.10 - #739

Merged
karel-rehor merged 3 commits into
influxdata:masterfrom
Solarboaters:fix/preserve-async-query-cancellation
Dec 2, 2026
Merged

karel-rehor merged 3 commits into
influxdata:masterfrom
Solarboaters:fix/preserve-async-query-cancellation

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Cancelling an async CSV query on Python 3.10 raises AttributeError instead of preserving CancelledError, because exception notes were introduced in Python 3.11. Only add the optional timeout hint when the exception supports it; keep re-raising the original exception and closing the response.

Adds a regression covering cancellation, timeout and ordinary parsing errors, checking exception identity, response cleanup, and notes on supported Python versions.

Validation (Linux, baseline 9a0910f):

  • Python 3.10.22: the cancellation and timeout cases fail before the fix. Afterward all 27 parser tests and three exception subcases pass.
  • Python 3.12.3: the same tests pass and preserve the diagnostic notes.
  • Ran the reporter's local aiohttp reproduction for all four public query methods: cancellation/completion checks improve from 4/8 to 8/8 on 3.10; 8/8 pass on 3.12. No production InfluxDB instance was used.
  • Changed-file flake8 passes. Whole-source flake8 reports the same two pre-existing E721 diagnostics in generated async/sync API clients. The full InfluxDB-dependent integration suite was not run.

Fixes #736. Thanks @Rajatendu1 for the detailed reproducer.

Checklist

  • CHANGELOG.md updated
  • Regression tests added
  • Conventional commit message
  • Full test suite passes
  • CLA signed by submitter, if required

@Solarboaters

Solarboaters commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

The CI failures exposed an interaction in the added regression test: asyncio.run() cleared the shared current loop used by later tests. I reproduced the ordering failure and changed the new test to create and close its own loop without changing the shared loop (500f927).

On Python 3.10 and 3.12, the parser tests plus four subsequent client-construction tests now pass together (31 tests and three subtests); all eight real loopback cancellation/completion scenarios also still pass on each version. The full CircleCI rerun is now green: all 13 checks passed, including the database-backed test jobs for Python 3.7–3.12 and the nightly/without-ciso8601 variants.

@codecov-commenter

codecov-commenter commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.75%. Comparing base (e99f6f0) to head (45a540a).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
+ Coverage   90.64%   90.75%   +0.11%     
==========================================
  Files          41       41              
  Lines        3591     3591              
==========================================
+ Hits         3255     3259       +4     
+ Misses        336      332       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bednar
bednar force-pushed the fix/preserve-async-query-cancellation branch from 500f927 to 386e929 Compare November 30, 2026 05:01
@karel-rehor
karel-rehor force-pushed the fix/preserve-async-query-cancellation branch from 386e929 to 7f52dd7 Compare December 1, 2026 13:36
@karel-rehor
karel-rehor force-pushed the fix/preserve-async-query-cancellation branch from 7f52dd7 to ada6345 Compare December 2, 2026 13:05

@karel-rehor karel-rehor left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Solarboaters Thank you for this contribution!

N.B. As a first time contributor please be aware that there are some nits that Influxdata likes to be sure are covered in PRs. To save a little time I've gone ahead and covered them already...

  1. All commit messages need to be semantic e.g. see gist
  2. The Checklist needs to be included in the description. This should have been in the PR template, so I'm not sure why it was not in the original description.
  3. Bug fixes, feature improvements and new features need to be added to CHANGELOG.md with a link to the PR that introduces them.
  4. Ideally the CLA should be signed, but with smaller changes like this one, it's not usually a blocker.

The additional check that an Exception actually has the add_note() method is a great help in maintaining stability with earlier python releases.

All tests are passing.

Looks good to me. 🚴 🏁

@karel-rehor
karel-rehor merged commit 354d881 into influxdata:master Dec 2, 2026
15 checks passed
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.

Async query cancellation raises AttributeError on Python 3.10 when adding an exception note

3 participants