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

Cover ttl=0 (expire always) _DNSCacheTable case (#7014) #7045

Conversation

laky55555
Copy link
Contributor

@laky55555 laky55555 commented Oct 25, 2022

Fix bug when using ttl_dns_cache=0

When using `ttl_dns_cache=0`, hostname is added to cache and on expire check there is a KeyError as it is never added into _timestamp dictionary.

Added a short description to docs ClientSession advising to use use_dns_cache instead of ttl_dns_cache=0 for always expiring cache.

Alternative to this change is to enforce user to use positive none 0 float or None for ttl_dns_cache during init time and in case of using 0 implicitly change use_dns_cache to False or raise exception. No.

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
  • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following: * .feature: Signifying a new feature. * .bugfix: Signifying a bug fix. * .doc: Signifying a documentation improvement. * .removal: Signifying a deprecation or removal of public API.
  • .misc: A ticket has been closed, but it is not of interest to users.
  • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

Co-authored-by: Sam Bull [email protected]
(cherry picked from commit 12f56d7)

What do these changes do?

Are there changes in behavior for the user?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

<!-- Thank you for your contribution! -->

Fix bug when using ttl_dns_cache=0

<!-- Please give a short brief about these changes. -->
When using `ttl_dns_cache=0`, hostname is added to cache and on expire
check there is a KeyError as it is never added into _timestamp
dictionary.
Added a short description to docs ClientSession advising to use
`use_dns_cache` instead of `ttl_dns_cache=0` for always expiring cache.

Alternative to this change is to enforce user to use positive none 0
float or None for `ttl_dns_cache` during init time and in case of using
0 implicitly change `use_dns_cache` to False or raise exception.
No.

<!-- Outline any notable behaviour for the end users. -->

<!-- Are there any issues opened that will be resolved by merging this
change? -->

- [X] I think the code is well written
- [X] Unit tests for the changes exist
- [X] Documentation reflects the changes
- [X] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
  * The format is &lt;Name&gt; &lt;Surname&gt;.
  * Please keep alphabetical order, the file is sorted by names.
- [X] Add a new news fragment into the `CHANGES` folder
  * name it `<issue_id>.<type>` for example (588.bugfix)
* if you don't have an `issue_id` change it to the pr id after creating
the pr
  * ensure type is one of the following:
    * `.feature`: Signifying a new feature.
    * `.bugfix`: Signifying a bug fix.
    * `.doc`: Signifying a documentation improvement.
    * `.removal`: Signifying a deprecation or removal of public API.
* `.misc`: A ticket has been closed, but it is not of interest to users.
* Make sure to use full sentences with correct case and punctuation, for
example: "Fix issue with non-ascii contents in doctest text files."

Co-authored-by: Sam Bull <[email protected]>
(cherry picked from commit 12f56d7)
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 25, 2022
@laky55555
Copy link
Contributor Author

Backport from #7014

@codecov
Copy link

codecov bot commented Oct 25, 2022

Codecov Report

Merging #7045 (08c66ee) into 3.9 (c5432b3) will increase coverage by 0.05%.
The diff coverage is 90.00%.

@@            Coverage Diff             @@
##              3.9    #7045      +/-   ##
==========================================
+ Coverage   97.25%   97.31%   +0.05%     
==========================================
  Files         103      103              
  Lines       30183    30198      +15     
  Branches     3738     3745       +7     
==========================================
+ Hits        29354    29386      +32     
+ Misses        633      617      -16     
+ Partials      196      195       -1     
Flag Coverage Δ
CI-GHA 97.20% <90.00%> (+0.05%) ⬆️
OS-Linux 96.86% <90.00%> (+0.05%) ⬆️
OS-Windows 94.36% <90.00%> (+0.21%) ⬆️
OS-macOS 96.48% <90.00%> (+<0.01%) ⬆️
Py-3.10.7 ?
Py-3.10.8 96.91% <90.00%> (?)
Py-3.11.0 96.33% <90.00%> (?)
Py-3.11.0-rc.2 ?
Py-3.7.14 ?
Py-3.7.15 96.67% <90.00%> (?)
Py-3.7.9 94.22% <90.00%> (?)
Py-3.8.10 94.14% <90.00%> (?)
Py-3.8.14 96.62% <90.00%> (+0.04%) ⬆️
Py-3.9.13 94.14% <90.00%> (?)
Py-3.9.14 96.38% <90.00%> (-0.23%) ⬇️
Py-3.9.15 96.61% <90.00%> (?)
Py-pypy7.3.9 96.21% <90.00%> (?)
VM-macos 96.48% <90.00%> (+<0.01%) ⬆️
VM-ubuntu 96.86% <90.00%> (+0.05%) ⬆️
VM-windows 94.36% <90.00%> (+0.21%) ⬆️

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

Impacted Files Coverage Δ
tests/test_connector.py 97.41% <88.88%> (-0.11%) ⬇️
aiohttp/connector.py 92.40% <100.00%> (ø)
tests/autobahn/test_autobahn.py 100.00% <0.00%> (+1.66%) ⬆️
aiohttp/web.py 99.15% <0.00%> (+1.68%) ⬆️
tests/conftest.py 92.38% <0.00%> (+1.90%) ⬆️
tests/autobahn/client/client.py 96.42% <0.00%> (+49.99%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Dreamsorcerer
Copy link
Member

Thanks.

@Dreamsorcerer Dreamsorcerer enabled auto-merge (squash) October 25, 2022 18:30
@Dreamsorcerer Dreamsorcerer merged commit a97b5e2 into aio-libs:3.9 Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants