Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XREAD command returns empty list if count is bigger than number of messages #256

Closed
sveta-afanaseva opened this issue Dec 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@sveta-afanaseva
Copy link

sveta-afanaseva commented Dec 5, 2023

Describe the bug
Command XREAD returns empty list when COUNT is bigger than count of messages in stream. However, in redis python sdk it works another way (it returns all messages from the stream)

Some proofs
https://github.com/redis/redis-py/blob/emb-examples/doctests/dt_stream.py#L43
https://redis.io/docs/data-types/streams/

To Reproduce
Steps to reproduce the behavior:

  1. Create FakeRedis object
  2. Add message in stream with command xadd
  3. Call xread command for your stream with argument count=100
  4. Get empty list

Expected behavior
Expected list of all messages in stream

Desktop (please complete the following information):

  • OS: Windows
  • python version 3.10
  • redis-py version 5.0.1
@sveta-afanaseva sveta-afanaseva added the bug Something isn't working label Dec 5, 2023
@cunla
Copy link
Owner

cunla commented Dec 5, 2023

Hi, can you provide the test for it? to run against real redis and fakeredis?

@sveta-afanaseva
Copy link
Author

sveta-afanaseva commented Dec 5, 2023

Yes, try this

from fakeredis import FakeRedis
from redis import Redis

def test_redis():
    fake_redis = FakeRedis()
    real_redis = Redis(host="localhost", port=6379)
    
    fake_redis.xadd("test", {"x": 1})
    real_redis.xadd("test", {"x": 1})
    
    res1 = fake_redis.xread(streams={"test": "0"}, count=100, block=10)
    res2 = real_redis.xread(streams={"test": "0"}, count=100, block=10)
    assert len(res1) == len(res2)

@sveta-afanaseva
Copy link
Author

Oh, sorry, it returns empty list, not None. My mistake

@sveta-afanaseva sveta-afanaseva changed the title XREAD command returns None if count is bigger than number of messages XREAD command returns empty list if count is bigger than number of messages Dec 5, 2023
@cunla cunla mentioned this issue Dec 5, 2023
@cunla
Copy link
Owner

cunla commented Dec 5, 2023

Ok, I wrote a test that is able to replicate it. I'll try to fix it this weekend.

@cunla cunla closed this as completed in 9ba929e Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants