-
Notifications
You must be signed in to change notification settings - Fork 72
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
Unlock queue on dequeue #3
base: master
Are you sure you want to change the base?
Conversation
@@ -3,6 +3,5 @@ source :rubygems | |||
gem "resque" | |||
|
|||
group :development do | |||
gem "turn" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't run tests with this gem. Was getting this error message:
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/test/unit/assertions.rb:5:in
module:Test': Unit is not a module (TypeError)`
The tests run without it and the rake file is testing if the command exists, so i figured it should be optional. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!
Still trying to think of a way to remove the locks when removing the whole queue. Since One way I thought to resolve this is to force the queue name on the lock. Something like this:
Then in the code of And then still need to be able to add a hook on I can try to implement this, let me know if you're interested :) |
Hey ... I've reverted back the hash change (for speed), so it now uses normal Redis keys again. I also added another class method for defining if the lock should be lifted or kept for running jobs. It was required in one project where it was important for jobs with same args to get queued even if the same job is running. I called it Enjoy ;) |
end | ||
|
||
def namespaced_lock(*args) | ||
"lock:#{lock(*args)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is namespaced_lock
defined with the same behaviour lock
used to have, but only use lock
in namespaced_lock
Unlocks a queue when dequeue is called, using the before dequeue hook (see: humancopy/resque@5042244).
It also stores the lock in a hash so it's easier to remove all locks if needed.
There are still deadlocks happening when using Resque.remove_queue to remove the whole queue. Still thinking on this one... :)