Use c-ares flags for asynchronous DNS resolution by JackyHsu-X · Pull Request #14088 · aio-libs/aiohttp · GitHub
Skip to content

Use c-ares flags for asynchronous DNS resolution - #14088

Open
JackyHsu-X wants to merge 2 commits into
aio-libs:masterfrom
JackyHsu-X:fix/async-resolver-cares-flags
Open

JackyHsu-X wants to merge 2 commits into
aio-libs:masterfrom
JackyHsu-X:fix/async-resolver-cares-flags

Conversation

@JackyHsu-X

@JackyHsu-X JackyHsu-X commented Oct 20, 2026 •

Copy link
Copy Markdown

What do these changes do?

Use c-ares flag values for AsyncResolver.getaddrinfo() and the scoped-IPv6 getnameinfo() call. The socket constants differ across platforms and aiodns/pycares pass them through unchanged. Keep socket flags for ThreadedResolver and for the returned ResolveResult.

The c-ares masks are defined locally because pycares does not publicly export ARES_AI_*. The values follow include/ares.h; this avoids depending on a private pycares API.

Are there changes in behavior for the user?

The asynchronous backend requests address-configuration filtering and numeric host/service output with the intended flags. Windows localhost retry still uses zero flags.

Is it a substantial burden for the maintainers to support this?

Two private constants and two call-site changes; no public API or dependency changes. Regression tests cover differing platform flag values, the existing localhost fallback, and a real numeric aiodns lookup.

Related issue number

Fixes #14087.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes — N/A: no API change; behavior correction recorded in the news fragment.
  • Contributor added to CONTRIBUTORS.txt
  • News fragment added to CHANGES/14087.bugfix.rst, with CHANGES/14088.bugfix.rst linking to it as requested in AGENTS.md.

Reviewed by @JackyHsu-X. Ready for maintainer review.

Local validation run by the agent (Windows, Python 3.12.8, pure Python mode)
  • Original production source with the updated resolver tests: 6 failed, 29 passed.
  • Fixed resolver suite: 35 passed; resolver coverage 96% (all changed production lines covered).
  • pytest tests/test_resolver.py tests/test_connector.py tests/test_client_proto.py -n 4 --no-cov -q: 259 passed, 6 skipped, 1 xfailed.
  • pytest tests/test_client_functional.py -n 4 --no-cov -q: 340 passed, 1 xfailed.
  • Real local HTTP GET through both AsyncResolver and ThreadedResolver: passed.
  • Mypy on the two changed Python files: passed. Full-repository Mypy reports 75 existing diagnostics, identical as a multiset when the two original source files are supplied with --shadow-file (Windows-only APIs and missing optional development dependencies among them).
  • All applicable pre-commit hooks pass on the four changed files. The all-files attempt encountered existing Windows symlink-stub checks and tooling compatibility issues; unrelated automatic edits were restored. Only local tool environments were adjusted, with no repository configuration changes.

The complete test suite, Linux matrix, and compiled extensions were not run. This change does not touch parsers or WebSockets.

Drafted with OpenAI Codex (GPT-6); reviewed by @JackyHsu-X.

@agentscanapp

agentscanapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.09%. Comparing base (72a735c) to head (0f902fe).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14088   +/-   ##
=======================================
  Coverage   99.09%   99.09%           
=======================================
  Files         135      135           
  Lines       53551    53566   +15     
  Branches     2809     2809           
=======================================
+ Hits        53067    53082   +15     
  Misses        364      364           
  Partials      120      120           
Flag Coverage Δ
Autobahn 21.70% <42.85%> (+<0.01%) ⬆️
CI-GHA 98.93% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.72% <100.00%> (-0.01%) ⬇️
OS-Windows 97.37% <100.00%> (+<0.01%) ⬆️
OS-macOS 98.24% <100.00%> (+<0.01%) ⬆️
Py-3.10 98.16% <100.00%> (+<0.01%) ⬆️
Py-3.11 98.40% <100.00%> (+<0.01%) ⬆️
Py-3.12 98.48% <100.00%> (+<0.01%) ⬆️
Py-3.13 98.47% <100.00%> (+<0.01%) ⬆️
Py-3.14 98.51% <100.00%> (+<0.01%) ⬆️
Py-3.15 98.50% <100.00%> (-0.01%) ⬇️
Py-3.15t 97.91% <100.00%> (+<0.01%) ⬆️
Py-pypy-3.12 96.56% <100.00%> (+<0.01%) ⬆️
VM-macos 98.24% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 98.72% <100.00%> (-0.01%) ⬇️
VM-windows 97.37% <100.00%> (+<0.01%) ⬆️
cython-coverage 83.56% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codspeed

codspeed Bot commented Oct 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 49 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 102 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing JackyHsu-X:fix/async-resolver-cares-flags (0f902fe) with master (9af1fce)2

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on master (72a735c) during the generation of this report, so 9af1fce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@JackyHsu-X
JackyHsu-X marked this pull request as ready for review October 21, 2026 13:34
@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncResolver passes socket module flags to c-ares instead of c-ares ones

1 participant