lib/backburner/workers/threads_on_fork.rb in backburner-allq-1.0.18 vs lib/backburner/workers/threads_on_fork.rb in backburner-allq-1.0.19
- old
+ new
@@ -179,10 +179,12 @@
@garbage_after = @tubes_data[name][:garbage] || self.class.garbage_after
@threads_number = (@tubes_data[name][:threads] || self.class.threads_number || 1).to_i
@runs = 0
+ puts "Threads number = #{@threads_number}"
+
if @threads_number == 1
watch_tube(name)
run_while_can
else
threads_count = Thread.list.count
@@ -203,14 +205,18 @@
coolest_exit
end
# Run work_one_job while we can
def run_while_can(conn = connection)
+ puts "Run while can"
while @garbage_after.nil? or @garbage_after > @runs
@runs += 1 # FIXME: Likely race condition
ran_job = work_one_job(conn)
# Wait a second if we didn't find a job
- sleep(rand() * 3) unless ran_job
+ unless ran_job
+ puts "sleeping"
+ sleep(rand() * 3)
+ end
end
end
# Shortcut for watching a tube on our beanstalk connection
def watch_tube(name, conn = connection)