diff --git a/redash/__init__.py b/redash/__init__.py index 9e84d0fbc9..7778e85c4b 100644 --- a/redash/__init__.py +++ b/redash/__init__.py @@ -138,11 +138,3 @@ def create_app(load_admin=True): users.init_app(app) return app - - -def safe_create_app(): - """Return current_app or create a new one.""" - if current_app: - return current_app - - return create_app() diff --git a/redash/worker.py b/redash/worker.py index 2edca47170..748c26381b 100644 --- a/redash/worker.py +++ b/redash/worker.py @@ -8,7 +8,7 @@ from celery import Celery from celery.schedules import crontab from celery.signals import worker_process_init -from redash import safe_create_app, settings +from redash import create_app, settings from redash.metrics import celery as celery_metrics celery = Celery('redash', @@ -74,14 +74,15 @@ def __call__(self, *args, **kwargs): # Create Flask app after forking a new worker, to make sure no resources are shared between processes. @worker_process_init.connect def init_celery_flask_app(**kwargs): - app = safe_create_app() + app = create_app() app.app_context().push() +# Commented until https://github.com/getredash/redash/issues/3466 is implemented. # Hook for extensions to add periodic tasks. -@celery.on_after_configure.connect -def add_periodic_tasks(sender, **kwargs): - app = safe_create_app() - periodic_tasks = getattr(app, 'periodic_tasks', {}) - for params in periodic_tasks.values(): - sender.add_periodic_task(**params) +# @celery.on_after_configure.connect +# def add_periodic_tasks(sender, **kwargs): +# app = safe_create_app() +# periodic_tasks = getattr(app, 'periodic_tasks', {}) +# for params in periodic_tasks.values(): +# sender.add_periodic_task(**params)