Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3874,7 +3874,7 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
self.reset()
self.execute() # also resets

def __del__(self):
try:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def test_pipeline_length(self, r):
pipe.execute()
assert len(pipe) == 0

def test_pipeline_autoexecute(self, r):
with r.pipeline() as pipe:
# Fill 'er up!
pipe.set('d', 'd1').set('e', 'e1').set('f', 'f1')
assert len(pipe) == 3

# exiting with block calls execute() and reset(), so empty once again
assert len(pipe) == 0

def test_pipeline_no_transaction(self, r):
with r.pipeline(transaction=False) as pipe:
pipe.set('a', 'a1').set('b', 'b1').set('c', 'c1')
Expand Down