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

Add nowait flag to asyncio.Connection.disconnect() #2356

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Aug 24, 2022

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

When the asyncio.Connection object encounters an exception, it often performs a self.disconnect(). This change
adds a nowait flag to this method, so that in the error case, disconnect() does not attempt to await a wait_closed() on the output stream. Awaiting a buffer method at this point can cause other errors to occur.
Notably an asyncio.CancelledError could happen, in case the entire operation is enclosed in a async_timeout.timeout() context manager.

At any rate, if the connection is in an error state, there is no need to wait for the write buffer flush.

This PR is separate from a related pr, #2104, both about making exception handling and cancelling (via Timeout) possible.

@kristjanvalur kristjanvalur force-pushed the pr_nowait branch 3 times, most recently from 6ca1c3b to 1cddc0b Compare August 25, 2022 10:02
@kristjanvalur kristjanvalur marked this pull request as ready for review August 25, 2022 11:40
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2022

Codecov Report

Base: 92.17% // Head: 92.17% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (ae80bf2) compared to base (9fe8366).
Patch coverage: 89.18% of modified lines in pull request are covered.

❗ Current head ae80bf2 differs from pull request most recent head 6208b66. Consider uploading reports for the commit 6208b66 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2356   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files         110      110           
  Lines       28924    28866   -58     
=======================================
- Hits        26661    26608   -53     
+ Misses       2263     2258    -5     
Impacted Files Coverage Δ
redis/asyncio/connection.py 86.65% <55.55%> (+0.03%) ⬆️
tests/test_asyncio/test_pubsub.py 99.33% <100.00%> (-0.04%) ⬇️
tests/test_pubsub.py 99.59% <0.00%> (-0.02%) ⬇️
tests/test_asyncio/test_cluster.py 97.41% <0.00%> (+0.13%) ⬆️
tests/conftest.py 85.71% <0.00%> (+0.77%) ⬆️
redis/commands/search/aggregation.py 79.72% <0.00%> (+0.84%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Aug 25, 2022
This can result in other errors such as timeouts.
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Aug 25, 2022
This can result in other errors such as timeouts.
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Aug 25, 2022
This can result in other errors such as timeouts.
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Aug 25, 2022
This can result in other errors such as timeouts.
@kristjanvalur kristjanvalur mentioned this pull request Aug 25, 2022
6 tasks
redis/asyncio/connection.py Outdated Show resolved Hide resolved
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Sep 19, 2022
This can result in other errors such as timeouts.
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Sep 26, 2022
This can result in other errors such as timeouts.
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Sep 28, 2022
This can result in other errors such as timeouts.
@dvora-h
Copy link
Collaborator

dvora-h commented Sep 29, 2022

@kristjanvalur Can you resolve the conflicts with master?

@dvora-h dvora-h changed the title asyncio.Connection.disconnect(nowait) Add nowait flag to asyncio.Connection.disconnect() Sep 29, 2022
kristjanvalur added a commit to mainframeindustries/redis-py that referenced this pull request Sep 29, 2022
This can result in other errors such as timeouts.
@dvora-h dvora-h merged commit 652ca79 into redis:master Sep 29, 2022
@kristjanvalur kristjanvalur deleted the pr_nowait branch September 29, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants