def _run_job(self, *args, **kwargs): with self.app.app_context(): Scheduler._old_run_job(self, *args, **kwargs)