Skip to content
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

trust_env=True of aiohttp.ClientSession should not print a warning log nor try to access each time a file #3298

Closed
siom79 opened this issue Sep 27, 2018 · 6 comments

Comments

@siom79
Copy link

siom79 commented Sep 27, 2018

Long story short

When setting trust_env=True for aiohttp.ClientSession, a warning like the following one is printed to the log if the file .netrc is missing.

2018-09-26 08:10:07 WARNING (MainThread) [aiohttp.client] could't find .netrc file

This should not happen as the intention is to only access environment variables. Beyond that, the file access should only happen once and not again and again for each instance of aiohttp.ClientSession. This is for example the reason why pull request 16874 for home-assistant was rejected.

Expected behaviour

Setting trust_env=True for aiohttp.ClientSession should not print a warning and should not try to access a file each time.

Actual behaviour

If the file .netrc is missing, a warning is printed and for each instance of aiohttp.ClientSession the file check is repeated.

Steps to reproduce

Create an instance of aiohttp.ClientSession with trust_env=True when there is no .netrc file.

Your environment

aiohttp version 3.4.4, used as client, running on Ubuntu 18.04 with python 3.6.6

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #2867 (aiohttp.ClientSession reconnect ), #919 (Suggesting aiohttp.ClientSession.abort()), #2209 (ClientSession.close() is a coroutine warning), #3248 (history tuple on ClientResponseError empty with raise_for_status() or ClientSession(raise_for_status=True)), and #975 (aiohttp.ClientSession raises ServerDisconnectedError).

@asvetlov
Copy link
Member

A warning is addressed by #3267

Regarding caching .netrc parsing results -- it could confuse people.
If we add caching it should be an opt-in configurable option I guess.

cooperlees added a commit to pypa/bandersnatch that referenced this issue Oct 30, 2018
- Works but has a bug at the moment of printing that ~/.netrc is missing
https://pastebin.com/tSYtrvjr
- Tracked here: aio-libs/aiohttp#3298
- Fixes #73
cooperlees added a commit to pypa/bandersnatch that referenced this issue Oct 30, 2018
- Works but has a bug at the moment of printing that ~/.netrc is missing
https://pastebin.com/tSYtrvjr
- Tracked here: aio-libs/aiohttp#3298
- Fixes #73
cooperlees added a commit to pypa/bandersnatch that referenced this issue Oct 30, 2018
- Works but has a bug at the moment of printing that ~/.netrc is missing
https://pastebin.com/tSYtrvjr
- Tracked here: aio-libs/aiohttp#3298
- Fixes #73
@cooperlees
Copy link

I see fixes for this are all landed - When do we expect a >= 3.4.4 release as I'd love to enable this for bandersnatch (as linked).

@asvetlov
Copy link
Member

asvetlov commented Nov 1, 2018

No release date is scheduled.
This month perhaps.

cooperlees added a commit to pypa/bandersnatch that referenced this issue Nov 17, 2018
- Works but has a bug at the moment of printing that ~/.netrc is missing
https://pastebin.com/tSYtrvjr
- Tracked here: aio-libs/aiohttp#3298
- Fixes #73
@asvetlov
Copy link
Member

asvetlov commented Dec 2, 2018

Logging is tuned, file access caching idea is rejected

@asvetlov asvetlov closed this as completed Dec 2, 2018
@lock
Copy link

lock bot commented Dec 2, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Dec 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants