Skip to content

Commit ea6c792

Browse files
committed
Fix bug with async pipeline fails with some commands
1 parent 2e46613 commit ea6c792

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

redis/asyncio/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,10 @@ async def _execute_transaction( # noqa: C901
14231423
if not isinstance(r, Exception):
14241424
args, options = cmd
14251425
command_name = args[0]
1426+
1427+
# Remove keys entry, it needs only for cache.
1428+
options.pop("keys", None)
1429+
14261430
if command_name in self.response_callbacks:
14271431
r = self.response_callbacks[command_name](r, **options)
14281432
if inspect.isawaitable(r):

tests/test_asyncio/test_pipeline.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,16 @@ async def test_pipeline_discard(self, r):
417417
response = await pipe.execute()
418418
assert response[0]
419419
assert await r.get("foo") == b"bar"
420+
421+
@pytest.mark.onlynoncluster
422+
async def test_send_set_commands_over_async_pipeline(self, r: redis.asyncio.Redis):
423+
pipe = r.pipeline()
424+
pipe.hset('hash:1', 'foo', 'bar')
425+
pipe.hset('hash:1', 'bar', 'foo')
426+
pipe.hset('hash:1', 'baz', 'bar')
427+
pipe.hgetall('hash:1')
428+
resp = await pipe.execute()
429+
assert resp == [
430+
1, 1, 1,
431+
{b'bar': b'foo', b'baz': b'bar', b'foo': b'bar'}
432+
]

tests/test_pipeline.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,16 @@ def test_pipeline_discard(self, r):
412412
response = pipe.execute()
413413
assert response[0]
414414
assert r.get("foo") == b"bar"
415+
416+
@pytest.mark.onlynoncluster
417+
def test_send_set_commands_over_pipeline(self, r: redis.Redis):
418+
pipe = r.pipeline()
419+
pipe.hset('hash:1', 'foo', 'bar')
420+
pipe.hset('hash:1', 'bar', 'foo')
421+
pipe.hset('hash:1', 'baz', 'bar')
422+
pipe.hgetall('hash:1')
423+
resp = pipe.execute()
424+
assert resp == [
425+
1, 1, 1,
426+
{b'bar': b'foo', b'baz': b'bar', b'foo': b'bar'}
427+
]

0 commit comments

Comments
 (0)