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

Support for floating point timeout values #289

Closed
darintay opened this issue Feb 12, 2024 · 1 comment
Closed

Support for floating point timeout values #289

darintay opened this issue Feb 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@darintay
Copy link

Describe the bug
Floating point timeouts are unsupported in fakeredis, they are reported as negative values and error out. They are supported in real Redis.

From the Redis docs, e.g.: https://redis.io/commands/blpop/
The timeout argument is interpreted as a double value specifying the maximum number of seconds to block

To Reproduce

>>> import fakeredis
>>> r = fakeredis.FakeRedis()
>>> r.blpop("mylist1", 1.1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/redis/commands/core.py", line 2594, in blpop
    return self.execute_command("BLPOP", *keys)
  File "/usr/local/lib/python3.10/dist-packages/redis/client.py", line 536, in execute_command
    return conn.retry.call_with_retry(
  File "/usr/local/lib/python3.10/dist-packages/redis/retry.py", line 46, in call_with_retry
    return do()
  File "/usr/local/lib/python3.10/dist-packages/redis/client.py", line 537, in <lambda>
    lambda: self._send_command_parse_response(
  File "/usr/local/lib/python3.10/dist-packages/redis/client.py", line 513, in _send_command_parse_response
    return self.parse_response(conn, command_name, **options)
  File "/usr/local/lib/python3.10/dist-packages/redis/client.py", line 553, in parse_response
    response = connection.read_response()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/fakeredis/_server.py", line 120, in read_response
    raise response
redis.exceptions.ResponseError: timeout is negative
>>> r.blpop("mylist1", 1)
>>> 

Expected behavior
Floating point timeouts should work.

Additional context
Thanks for making this great tool, super useful for tests!

@darintay darintay added the bug Something isn't working label Feb 12, 2024
@cunla
Copy link
Owner

cunla commented Feb 13, 2024

Thanks for bringing this up. I will fix it during the weekend.

@cunla cunla closed this as completed Feb 13, 2024
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