lib/resque/scheduler.rb in resque-scheduler-2.5.2 vs lib/resque/scheduler.rb in resque-scheduler-2.5.3

- old
+ new

@@ -127,11 +127,10 @@ update_schedule if dynamic rescue Errno::EAGAIN, Errno::ECONNRESET => e log! e.message end end - handle_signals poll_sleep end rescue Interrupt log 'Exiting' @@ -383,24 +382,33 @@ # Sleeps and returns true def poll_sleep handle_shutdown do begin - begin - @sleeping = true - sleep poll_sleep_amount - @sleeping = false - rescue Interrupt - if @shutdown - Resque.clean_schedules - release_master_lock! - end - end + poll_sleep_loop ensure @sleeping = false end end true + end + + def poll_sleep_loop + @sleeping = true + start = Time.now + loop do + break if (Time.now - start) >= poll_sleep_amount + begin + sleep 0.01 + handle_signals + rescue Interrupt + if @shutdown + Resque.clean_schedules + release_master_lock! + end + break + end + end end # Sets the shutdown flag, clean schedules and exits if sleeping def shutdown return if @shutdown