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

Recognize the lock state of multiple semaphores using the same key #45

Open
eugenk opened this issue Jul 9, 2016 · 1 comment · May be fixed by #46
Open

Recognize the lock state of multiple semaphores using the same key #45

eugenk opened this issue Jul 9, 2016 · 1 comment · May be fixed by #46

Comments

@eugenk
Copy link
Contributor

eugenk commented Jul 9, 2016

When you have many semaphore instances with the same key, only the one that called lock knows that the semaphore is locked, but all of them should find the correct state with locked?. Example of the faulty behavior:

[1] pry(main)> redis_sema = Redis::Semaphore.new(:my_sema)
=> #<Redis::Semaphore:0x007fc6d8c8aae0
 @expiration=nil,
 @name=:my_sema,
 @redis=#<Redis client v3.3.0 for redis://127.0.0.1:6379/0>,
 @resource_count=1,
 @stale_client_timeout=nil,
 @tokens=[],
 @use_local_time=nil>
[2] pry(main)> redis_sema.lock
=> "0"
[3] pry(main)> redis_sema2 = Redis::Semaphore.new(:my_sema)
=> #<Redis::Semaphore:0x007fc6d8b480d8
 @expiration=nil,
 @name=:my_sema2,
 @redis=#<Redis client v3.3.0 for redis://127.0.0.1:6379/0>,
 @resource_count=1,
 @stale_client_timeout=nil,
 @tokens=[],
 @use_local_time=nil>
[4] pry(main)> redis_sema2.locked?
=> false
[5] pry(main)> redis_sema.locked?
=> true
@NickDiMucci
Copy link

I'm actually running into the same issue. It would have been great if your PR was merged in.

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

Successfully merging a pull request may close this issue.

2 participants