Skip to content

Commit

Permalink
fix:simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed May 14, 2024
1 parent b8b8948 commit cc29d24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fakeredis/_basefakesocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _blocking(self, timeout: Optional[Union[float, int]], func: Callable[[bool],
Returns the function return value, or None if the timeout has passed.
"""
ret = func(True)
ret = func(True) # Call with first_pass=True
if ret is not None or self._in_transaction:
return ret
deadline = time.time() + timeout if timeout else None
Expand All @@ -231,7 +231,7 @@ def _blocking(self, timeout: Optional[Union[float, int]], func: Callable[[bool],
return None
if self._db.condition.wait(timeout=timeout) is False:
return None # Timeout expired
ret = func(False)
ret = func(False) # Second pass => first_pass=False
if ret is not None:
return ret

Expand Down
2 changes: 1 addition & 1 deletion fakeredis/aioredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __init__(
server: Optional[_server.FakeServer] = None,
connected: bool = True,
version: VersionType = (7,),
lua_modules: Set[str] = None,
lua_modules: Optional[Set[str]] = None,
**kwargs: Any,
) -> None:
if not connection_pool:
Expand Down
4 changes: 2 additions & 2 deletions fakeredis/commands_mixins/streams_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ def _xread(self, stream_start_id_list: List[Tuple[bytes, StreamRangeTest]], coun
stream_results = self._xrange(item.value, start_id, max_inf, False, count)
if len(stream_results) > 0:
res.append([item.key, stream_results])
if first_pass and (count is None) and len(res) == len(stream_start_id_list):
return res

# On blocking read, when count is not None, and there are no results, return None (instead of an empty list)
if blocking and count and len(res) == 0:
return None
return res
Expand Down

0 comments on commit cc29d24

Please sign in to comment.