kellyredding/inbox-sync — pull request #4 by kellyredding (2012-06-05 23:05:47+00:00)
Title: Better runner interrupt behavior

The whole point of this is to alter the runner behavior to capture
interrupts in a way that minimizing shutdown time while ensuring
a processing mail item is never interrupted.

This breaks up the runner looping algorithm and allows for runner
interruption. When an interrupt signal is trapped (`SIGINT`,
`SIGQUIT`, `TERM`), an `Interrupt exception is raised. This
allows a runner to be interrupted even if in an interval sleep.

The runner will always insure the sync thread joins in before
exiting. The sync checks if the runner has been signaled to
shutdown while processing mail items, so the sync thread
should at most finish its current mail item before aborting
and joining the main thread.