Skip to content

Commit 63a7864

Browse files
committed
fix: do not use asyncio's timeout lib before 3.11.2
There's an issue in asyncio's timeout lib before 3.11.3 that causes async calls to raise `CancelledError`. This is a cpython issue that was fixed in this commit [1] and cherry-picked to previous versions, meaning 3.11.3 will work correctly. Check [2] for more info. [1] python/cpython@04adf2d [2] redis#2633
1 parent 66a4d6b commit 63a7864

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Diff for: redis/asyncio/connection.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
)
2626
from urllib.parse import ParseResult, parse_qs, unquote, urlparse
2727

28-
if sys.version_info.major >= 3 and sys.version_info.minor >= 11:
28+
# the functionality is available in 3.11.x but has a major issue before
29+
# 3.11.3. See https://github.com/redis/redis-py/issues/2633
30+
if sys.version_info >= (3, 11, 3):
2931
from asyncio import timeout as async_timeout
3032
else:
3133
from async_timeout import timeout as async_timeout

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
install_requires=[
3535
'importlib-metadata >= 1.0; python_version < "3.8"',
3636
'typing-extensions; python_version<"3.8"',
37-
'async-timeout>=4.0.2; python_version<"3.11"',
37+
'async-timeout>=4.0.2; python_version<="3.11.2"',
3838
],
3939
classifiers=[
4040
"Development Status :: 5 - Production/Stable",

Diff for: tests/test_asyncio/test_pubsub.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from typing import Optional
66
from unittest.mock import patch
77

8-
if sys.version_info.major >= 3 and sys.version_info.minor >= 11:
8+
# the functionality is available in 3.11.x but has a major issue before
9+
# 3.11.3. See https://github.com/redis/redis-py/issues/2633
10+
if sys.version_info >= (3, 11, 3):
911
from asyncio import timeout as async_timeout
1012
else:
1113
from async_timeout import timeout as async_timeout

0 commit comments

Comments
 (0)