Skip to content

Commit b62a2e9

Browse files
committed
reserve configurably returns nil if a named queue has more than a configurable number of jobs in it
1 parent d47fcd4 commit b62a2e9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ spec/reports
1515
test/tmp
1616
test/version_tmp
1717
tmp
18+
*~

lib/resque/plugins/round_robin/round_robin.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ def should_work_on_queue? queuename
3939
end
4040

4141
def reserve_with_round_robin
42+
43+
# DJs hack: allow this resque process to watch a named queue
44+
# (python), and if that queue has more than a certain number of
45+
# items on it, then we do nothing. This is a big hack to get
46+
# around the lack of round-robining in pyres.
47+
if ENV["RESQUE_DEPENDENT_ON"].present?
48+
if Resque.size(ENV["RESQUE_DEPENDENT_ON"]) > ENV["RESQUE_DEPENDENT_MAX"]
49+
return nil
50+
end
51+
end
52+
4253
qs = rotated_queues
4354
qs.each do |queue|
4455
log! "Checking #{queue}"

0 commit comments

Comments
 (0)