Also pep8 fixes
Copy the stuff over from http pusher that prevents multiple instances of process running at once and sets up logging and measure blocks.
Mostly logic of when to send an email