-
-
Couldn't load subscription status.
- Fork 2.1k
Fix blocking I/O to load netrc when creating requests #11634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes blocking I/O in the event loop when netrc authentication is used by moving netrc file lookup from synchronous execution in ClientRequest.__init__() to asynchronous execution in ClientSession._request() using loop.run_in_executor().
- Moved netrc authentication lookup from
ClientRequest.update_auth()toClientSession._request() - Added environment variable check to avoid unnecessary executor jobs when NETRC is not set
- Removed blocking I/O allowances from test configuration
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| aiohttp/client.py | Added async netrc auth lookup in _request() method and helper _get_netrc_auth() |
| aiohttp/client_reqrep.py | Removed synchronous netrc auth logic from update_auth() method |
| tests/test_client_session.py | Added comprehensive tests for netrc authentication scenarios |
| tests/test_client_functional.py | Added functional tests for netrc authentication behavior |
| tests/test_client_request.py | Removed test that relied on synchronous netrc lookup |
| tests/conftest.py | Removed blocking I/O allowances and added netrc test fixtures |
| CHANGES/11634.bugfix.rst | Added changelog entry for the fix |
| CHANGES/10435.bugfix.rst | Added reference to the main bugfix changelog |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11634 +/- ##
=======================================
Coverage 98.74% 98.74%
=======================================
Files 127 127
Lines 43467 43529 +62
Branches 2327 2327
=======================================
+ Hits 42922 42984 +62
Misses 389 389
Partials 156 156
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
for more information, see https://pre-commit.ci
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…rc_blockingio_fix
Co-authored-by: Sam Bull <[email protected]>
Backport to 3.13: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply cde03b9 on top of patchback/backports/3.13/cde03b98c647272cf12f6e36cce35b5dc252171d/pr-11634 Backporting merged PR #11634 into master
🤖 @patchback |
Backport to 3.14: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply cde03b9 on top of patchback/backports/3.14/cde03b98c647272cf12f6e36cce35b5dc252171d/pr-11634 Backporting merged PR #11634 into master
🤖 @patchback |
|
Let me see if I can do the back ports this morning. I've been a bit under water with ESPHome release items |
|
Bit of a hairy conflict |
(cherry picked from commit cde03b9)
(cherry picked from commit cde03b9)
What do these changes do?
Fixes blocking I/O in the event loop when netrc authentication is used. Previously,
netrc_from_env()was called synchronously inClientRequest.__init__(), which would block the entire event loop while reading~/.netrcfrom disk.Now netrc lookup happens asynchronously in
ClientSession._request()usingloop.run_in_executor()before creating the request. Added a quick check for theNETRCenvironment variable to avoid spawning executor jobs unnecessarily since they're expensive.Are there changes in behavior for the user?
No user-facing changes. Netrc authentication still works exactly the same way - it just won't block the event loop anymore.
Is it a substantial burden for the maintainers to support this?
no
Related issue number
Fixes #10435
Checklist
CONTRIBUTORS.txtCHANGES/foldername it
<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst)if you don't have an issue number, change it to the pull request
number after creating the PR
.bugfix: A bug fix for something the maintainers deemed animproper undesired behavior that got corrected to match
pre-agreed expectations.
.feature: A new behavior, public APIs. That sort of stuff..deprecation: A declaration of future API removals and breakingchanges in behavior.
.breaking: When something public is removed in a breaking way.Could be deprecated in an earlier release.
.doc: Notable updates to the documentation structure or buildprocess.
.packaging: Notes for downstreams about unobvious side effectsand tooling. Changes in the test invocation considerations and
runtime assumptions.
.contrib: Stuff that affects the contributor experience. e.g.Running tests, building the docs, setting up the development
environment.
.misc: Changes that are hard to assign to any of the abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
Use the past tense or the present tense a non-imperative mood,
referring to what's changed compared to the last released version
of this project.