Skip to content

Commit

Permalink
fix: do not use asyncio's timeout lib before 3.11.2 (#2659)
Browse files Browse the repository at this point in the history
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] #2633
  • Loading branch information
bellini666 authored Mar 27, 2023
1 parent 66a4d6b commit 4802530
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
)
from urllib.parse import ParseResult, parse_qs, unquote, urlparse

if sys.version_info.major >= 3 and sys.version_info.minor >= 11:
# 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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
install_requires=[
'importlib-metadata >= 1.0; python_version < "3.8"',
'typing-extensions; python_version<"3.8"',
'async-timeout>=4.0.2; python_version<"3.11"',
'async-timeout>=4.0.2; python_version<="3.11.2"',
],
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
4 changes: 3 additions & 1 deletion tests/test_asyncio/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from typing import Optional
from unittest.mock import patch

if sys.version_info.major >= 3 and sys.version_info.minor >= 11:
# 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
Expand Down

0 comments on commit 4802530

Please sign in to comment.