- Notifications
You must be signed in to change notification settings - Fork 2.6k
Optionally disable disconnects in read_response #2695
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
Changes from 1 commit
a1d5a9b 7c2e955 087d994 18bc9ed 5437f7a b9d05e4 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,11 @@ | ||||||||||||||||||
| """ | ||||||||||||||||||
| Tests async overrides of commands from their mixins | ||||||||||||||||||
| """ | ||||||||||||||||||
| import asyncio | ||||||||||||||||||
| import binascii | ||||||||||||||||||
| import datetime | ||||||||||||||||||
| import re | ||||||||||||||||||
| import sys | ||||||||||||||||||
| from string import ascii_letters | ||||||||||||||||||
| | ||||||||||||||||||
| import pytest | ||||||||||||||||||
| | @@ -18,6 +20,11 @@ | |||||||||||||||||
| skip_unless_arch_bits, | ||||||||||||||||||
| ) | ||||||||||||||||||
| | ||||||||||||||||||
| if sys.version_info.major >= 3 and sys.version_info.minor >= 11: | ||||||||||||||||||
| ||||||||||||||||||
| if sys.version_info.major >= 3 and sys.version_info.minor >= 11: | |
| if sys.version_info >= (3, 11): |
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.
I guess we also want to use (3, 11, 3) here based on the following existing code?
redis-py/redis/asyncio/connection.py
Lines 28 to 33 in 7fc4c76
| # the functionality is available in 3.11.x but has a major issue before | |
| # 3.11.3. See https://github.com/redis/redis-py/issues/2633 | |
| if sys.version_info >= (3, 11, 3): | |
| from asyncio import timeout as async_timeout | |
| else: | |
| from async_timeout import timeout as async_timeout |
Outdated
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.
Ditto.
| if sys.version_info.major >= 3 and sys.version_info.minor >= 11: | |
| if sys.version_info >= (3, 11): |
Outdated
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.
This looks highly dubious; at least it should never ever be necessary here. Is this a workaround for the stdlib bug fixed in v3.11.3?
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.
No, it is necessary in current Python if you decide catch and ignore a Cancel request.
I am the author of pr python/cpython#102815 which fixed the Timeout issue in 3.11.3, and among other things, that PR clarifies this use case. Please see https://github.com/python/cpython/blob/main/Doc/library/asyncio-task.rst#task-cancellation
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.
Oh, I see now. This is necessary since you're catching CancelledError above.
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.
Why do you add this asterisk? I prefer not to break... (if someone is using something like read_response(False, 0.5))
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.
Ah, it was an afterghought. I was the one who added the timeout argument originally and in retrospect it probably should have been a keyword-only argument. Since it was my addition, I thought changing it retro-actively to a kw-only would be ok (there was only a two-month inverval between those two changes). "timeout" is traditionally a kw-only arg these days.
I guess one should be careful with these things, so I´m moving the asterisk :)