mozilla/socorro — pull request #1705 by twobraids (2013-12-03 22:30:39+00:00)
Title: NO MERGY - threadless task manager

this is the groundwork for making different task managers that will allow FTS based apps to run with threads, single threaded, processes, greenlets or whatever processing model one could come up with. In this first iteration, the ThreadedTaskManager is shunted off to a derived class of a single threaded TaskManager.

To use the processor as a single threaded app, just change the configured consumer_producer class to TaskManager instead of ThreadedTaskManager. A far as the processor is concerned, it cannot tell anything has changed.

In the future, if the TaskManager is to use some cooperative multitasking scheme like Greenlets, the polling infrastructure for termination testing (all those self.quit_check() calls scattered throughout the code) becomes instead the yield statements required by cooperative multitasking. This makes the change transparent to the processor.

To accomplish all this, logging had to be changed to allow easier identification of what unit of execution (thread or greenlet) is doing the logging. That's the LoggerWrapper that encapsulates the logging objects and calls the underlying logger methods with the identifier for the unit of execution.

In at least one place, exception handling had to be enhanced to prevent an exception from derailing the single threaded execution.