Ejemplo n.º 1
0
class Cron(Command):
    """
    """

    def __init__(self):
        self.cron = CronTab()

    def with_app_context(self, fn):
        @wraps(fn)
        def _fn(*args, **kwargs):
            with app.app_context():
                with app.cli_request_context():
                    return fn(*args, **kwargs)

        return _fn

    def onexit(self, *args, **kwargs):
        if self.cron.stop():
            import sys
            sys.exit(0)

    def run(self):
        gevent.signal(signal.SIGTERM, self.onexit)
        gevent.signal(signal.SIGINT, self.onexit)
 
        try:
            self.cron.start()
        except KeyboardInterrupt:
            self.cron.stop()
Ejemplo n.º 2
0
 def __init__(self):
     self.cron = CronTab()