@@ -0,0 +1,837 @@
+import gevent%0Aimport logging%0A%0Alogger = logging.getLogger(__name__)%0A%0A%0Aclass Worker(object):%0A%0A    def __init__(self, target, *args, **kwargs):%0A        self.run_func = target%0A        try:%0A            self.name = self.run_func.__name__%0A        except AttributeError:%0A            self.name = self.run_func.func.__name__%0A        self.target_args = args%0A        self.target_kwargs = kwargs%0A%0A    def _monitor(self, failed_g):%0A        msg = failed_g.exception%0A        logger.fatal('Error %7B%7D on %7B%7D'.format(msg, self.name))%0A        failed_g.kill()%0A        gevent.sleep(1)%0A        logger.info('Starting %7B%7D'.format(self.name))%0A        self.start()%0A%0A    def start(self):%0A        g = gevent.spawn(self.run_func,%0A                         *self.target_args,%0A                         **self.target_kwargs)%0A        g.link(self._monitor)%0A        self.g = g%0A

Add greenlet monitor for databrodge workers