mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
ensure that after applying weights, all queues are represented in the blpop command
This commit is contained in:
parent
e65c6fcd3d
commit
bceacec766
1 changed files with 4 additions and 4 deletions
|
@ -16,7 +16,7 @@ module Sidekiq
|
|||
def initialize(mgr, queues)
|
||||
@mgr = mgr
|
||||
@queues = queues.map { |q| "queue:#{q}" }
|
||||
@num_queues = queues.uniq.size
|
||||
@unique_queues = @queues.uniq
|
||||
end
|
||||
|
||||
# Fetching is straightforward: the Manager makes a fetch
|
||||
|
@ -49,9 +49,9 @@ module Sidekiq
|
|||
# recreate the queue command each time we invoke Redis#blpop
|
||||
# to honor weights and avoid queue starvation.
|
||||
def queues_cmd
|
||||
cmd = @queues.sample(@num_queues)
|
||||
cmd << TIMEOUT
|
||||
cmd
|
||||
queues = @queues.sample(@unique_queues.size).uniq
|
||||
queues.concat(@unique_queues - queues)
|
||||
queues << TIMEOUT
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue