resque/resque-scheduler — pull request #436 by errant01 (2014-08-07 21:38:55+00:00)
Title: Issue 434 - enabling poll sleep loop to break out with TERM signals when sleep amount = 0

The poll_sleep_loop will not exit on kill -s TERM commands to the scheduler process. This is because the check for whether the sleep time has passed does a break without running handle signals, assuming there will be a time at some point where remaining_sleep will be > 0. This can't be met with poll_sleep_amount set to 0.

I updated the code to check for 0 and explicity run the handle_signals code. This caused repetition so I pulled the handle_signals code block out into a method that can accept a block to run before handle_signals is called. I also added a test for this case.