File tree 1 file changed +19
-5
lines changed
1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -895,12 +895,26 @@ async def read_response(
895
895
):
896
896
"""Read the response from a previously sent command"""
897
897
read_timeout = timeout if timeout is not None else self .socket_timeout
898
- lock_ctxt = self ._lock if with_lock else nullcontext
899
898
try :
900
- async with lock_ctxt , async_timeout .timeout (read_timeout ):
901
- response = await self ._parser .read_response (
902
- disable_decoding = disable_decoding
903
- )
899
+ if with_lock :
900
+ if read_timeout is not None :
901
+ async with self ._lock , async_timeout .timeout (read_timeout ):
902
+ response = await self ._parser .read_response (
903
+ disable_decoding = disable_decoding
904
+ )
905
+ else :
906
+ async with self ._lock :
907
+ self ._parser .read_response (disable_decoding = disable_decoding )
908
+ else :
909
+ if read_timeout is not None :
910
+ async with async_timeout .timeout (read_timeout ):
911
+ response = await self ._parser .read_response (
912
+ disable_decoding = disable_decoding
913
+ )
914
+ else :
915
+ response = await self ._parser .read_response (
916
+ disable_decoding = disable_decoding
917
+ )
904
918
except asyncio .TimeoutError :
905
919
if timeout is not None :
906
920
# user requested timeout, return None
You can’t perform that action at this time.
0 commit comments