Browse files

Move reporting and control code outside the loop callback block

This triggers a LocalJumpError in jruby
  • Loading branch information...
1 parent d663d06 commit 475b081d95182bce883959e6e47bea21c55c0dc3 @albus522 albus522 committed Jan 24, 2013
Showing with 11 additions and 16 deletions.
  1. +11 −16 lib/delayed/worker.rb
View
27 lib/delayed/worker.rb
@@ -129,27 +129,22 @@ def start
self.class.lifecycle.run_callbacks(:execute, self) do
loop do
self.class.lifecycle.run_callbacks(:loop, self) do
- result = nil
-
- realtime = Benchmark.realtime do
- result = work_off
+ @realtime = Benchmark.realtime do
+ @result = work_off
end
+ end
- count = result.sum
-
- break if stop?
+ count = @result.sum
- if count.zero?
- if self.class.exit_on_complete
- say "No more jobs available. Exiting"
- stop
- break
- else
- sleep(self.class.sleep_delay)
- end
+ if count.zero?
+ if self.class.exit_on_complete
+ say "No more jobs available. Exiting"
+ break
else
- say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last]
+ sleep(self.class.sleep_delay) unless stop?
end
+ else
+ say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / @realtime, @result.last]
end
break if stop?

0 comments on commit 475b081

Please sign in to comment.