Skip to content

Commit 3e5830b

Browse files
jakob-kellergerzse
authored andcommitted
Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3068)
1 parent 7b3f0d6 commit 3e5830b

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* Improve error output for master discovery
6262
* Make `ClusterCommandsProtocol` an actual Protocol
6363
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
64+
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
6465

6566
* 4.1.3 (Feb 8, 2022)
6667
* Fix flushdb and flushall (#1926)

redis/asyncio/cluster.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,8 @@ def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None:
14331433
self._command_stack = []
14341434

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

14381439
def __len__(self) -> int:
14391440
return len(self._command_stack)

tests/test_asyncio/test_pipeline.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

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

0 commit comments

Comments
 (0)