Skip to content

Incorrect implementation of timeout = 0 in blocking calls? #216

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

Open
Crentist opened this issue Oct 9, 2018 · 1 comment
Open

Incorrect implementation of timeout = 0 in blocking calls? #216

Crentist opened this issue Oct 9, 2018 · 1 comment

Comments

@Crentist
Copy link

Crentist commented Oct 9, 2018

Blocking commands such as BLPOP and BRPOP in Redis block indefinitely when the timeout value is zero. redis-rb does the same when a timeout is not provided (it defaults to 0 and thus blocks indefinitely). This doesn't seem to be the behavior implemented by the gem:

def blpop(keys, timeout=0)
  #todo threaded mode
  keys = Array(keys)
  keys.each do |key|
    if data[key] && data[key].size > 0
      return [key, data[key].shift]
    end
  end
  sleep(timeout.to_f)
  nil
end

as it sleeps for zero seconds instead of blocking.

@guilleiguaran
Copy link
Owner

Thanks for reporting this.

Do you think you can send a PR to fix the behavior of fakeredis in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants