Skip to content

Commit

Permalink
Prevent async ClusterPipeline instances from becoming "false-y" in ca…
Browse files Browse the repository at this point in the history
…se of empty command stack (#3068)
  • Loading branch information
jakob-keller committed Dec 11, 2023
1 parent ce9eb83 commit 3502c4d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* Improve error output for master discovery
* Make `ClusterCommandsProtocol` an actual Protocol
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)

* 4.1.3 (Feb 8, 2022)
* Fix flushdb and flushall (#1926)
Expand Down
3 changes: 2 additions & 1 deletion redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,8 @@ def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None:
self._command_stack = []

def __bool__(self) -> bool:
return bool(self._command_stack)
"Pipeline instances should always evaluate to True on Python 3+"
return True

def __len__(self) -> int:
return len(self._command_stack)
Expand Down
1 change: 0 additions & 1 deletion tests/test_asyncio/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestPipeline:
@pytest.mark.onlynoncluster
async def test_pipeline_is_true(self, r):
"""Ensure pipeline instances are not false-y"""
async with r.pipeline() as pipe:
Expand Down

0 comments on commit 3502c4d

Please sign in to comment.