diff options
Diffstat (limited to 'lib/rainbows/fiber/base.rb')
-rw-r--r-- | lib/rainbows/fiber/base.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index 00af214..e8f5b16 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -51,8 +51,16 @@ module Rainbows::Fiber::Base end } fibs.each { |fib| fib.resume } - now = Time.now - max.nil? || max > (now + 1) ? 1 : max - now + + max_sleep = 1.0 # wake up semi-frequently to prevent SIGKILL from master + if max + max -= Time.now + return 0 if max < 0.0 + return max_sleep if max > max_sleep + max + else + max_sleep + end end def process(client) |