Example #1
0
    def test_factory_works(self):
        self.mox.StubOutWithMock(instances, 'PeriodicAdministrativeJob')

        instances.PeriodicAdministrativeJob(self.app, 10.0,
                                            instances.rip_expired_instances)\
                .AndReturn('T1')
        instances.PeriodicAdministrativeJob(self.app, 60.0,
                                            instances.remind_about_instances)\
                .AndReturn('T2')
        instances.PeriodicAdministrativeJob(self.app, 2400.0,
                                            instances.instance_data_gc)\
                .AndReturn('T3')

        self.mox.ReplayAll()
        result = instances.jobs_factory(self.app)
        self.assertEquals(result, ['T1', 'T2', 'T3'])
Example #2
0
    def test_factory_works(self):
        self.mox.StubOutWithMock(instances, 'PeriodicAdministrativeJob')

        instances.PeriodicAdministrativeJob(self.app, 10.0,
                                            instances.rip_expired_instances)\
                .AndReturn('T1')
        instances.PeriodicAdministrativeJob(self.app, 60.0,
                                            instances.remind_about_instances)\
                .AndReturn('T2')
        instances.PeriodicAdministrativeJob(self.app, 2400.0,
                                            instances.instance_data_gc)\
                .AndReturn('T3')

        self.mox.ReplayAll()
        result = instances.jobs_factory(self.app)
        self.assertEquals(result, ['T1', 'T2', 'T3'])
Example #3
0
def main():
    app = make_app()
    setup_logging(app)

    if not check_connection(app):
        sys.exit(1)

    periodic_jobs = []
    if not app.config['USE_RELOADER'] \
       or os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
        periodic_jobs.extend(instances_jobs.jobs_factory(app))
    try:
        app.run(use_reloader=app.config['USE_RELOADER'],
                host=app.config['HOST'],
                port=app.config['PORT'])
    finally:
        for job in periodic_jobs:
            try:
                job.cancel()
            except Exception:
                pass
Example #4
0
def main():
    app = make_app()
    setup_logging(app)

    if not check_connection(app):
        sys.exit(1)

    periodic_jobs = []
    if not app.config['USE_RELOADER'] \
       or os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
        periodic_jobs.extend(instances_jobs.jobs_factory(app))
    try:
        app.run(use_reloader=app.config['USE_RELOADER'],
                host=app.config['HOST'],
                port=app.config['PORT'])
    finally:
        for job in periodic_jobs:
            try:
                job.cancel()
            except Exception:
                pass