Skip to content

Commit 3502c4d

Browse files
authored
Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3068)
1 parent ce9eb83 commit 3502c4d

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
@@ -57,6 +57,7 @@
5757
* Improve error output for master discovery
5858
* Make `ClusterCommandsProtocol` an actual Protocol
5959
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
60+
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
6061

6162
* 4.1.3 (Feb 8, 2022)
6263
* Fix flushdb and flushall (#1926)

redis/asyncio/cluster.py

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

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

14341435
def __len__(self) -> int:
14351436
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)