Skip to content

Commit 305f848

Browse files
committed
expand with statement to avoid invoking null context managers.
remove nullcontext
1 parent 36fda7b commit 305f848

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

redis/asyncio/connection.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import contextlib
32
import copy
43
import enum
54
import inspect
@@ -55,19 +54,6 @@
5554
if HIREDIS_AVAILABLE:
5655
import hiredis
5756

58-
if sys.version_info[:2] >= (3, 10):
59-
nullcontext = contextlib.nullcontext()
60-
else:
61-
62-
class NullContext:
63-
async def __aenter__(self):
64-
pass
65-
66-
async def __aexit__(self, *args):
67-
pass
68-
69-
nullcontext = NullContext()
70-
7157
SYM_STAR = b"*"
7258
SYM_DOLLAR = b"$"
7359
SYM_CRLF = b"\r\n"
@@ -891,7 +877,12 @@ async def read_response(
891877
"""Read the response from a previously sent command"""
892878
read_timeout = timeout if timeout is not None else self.socket_timeout
893879
try:
894-
async with async_timeout.timeout(read_timeout):
880+
if read_timeout is not None:
881+
async with async_timeout.timeout(read_timeout):
882+
response = await self._parser.read_response(
883+
disable_decoding=disable_decoding
884+
)
885+
else:
895886
response = await self._parser.read_response(
896887
disable_decoding=disable_decoding
897888
)

0 commit comments

Comments
 (0)