Error running query: Working outside of application context

#1

Issue Summary

Error running query: Working outside of application context

Technical details:

env: win10 64bit
version: redash7.0.0(dev)
python: python2.7.15
IDE: pycharm2019.1 X64

npm: run watch
celery:celery worker --app=redash.worker --pool=eventlet -Qscheduled_queries,queries,celery -c2
flask:FLASK_APP = redash.wsgi
FLASK_ENV = development
FLASK_DEBUG = 1
python -m flask run

redash is running like ok. http://localhost:5000 can work;
but when use queries,excute error

Error running query: Working outside of application context. This typically means that you attempted to use functionality that needed to interface with the current application object in a way. To solve this set up an application context with app.app_context(). See the documentation for more information.

i think the worker.py run not good.

    def __call__(self, *args, **kwargs):
        with current_app.app_context():
            return TaskBase.__call__(self, *args, **kwargs)


@worker_process_init.connect
def init_celery_flask_app(**kwargs):
    app = create_app()
    app.app_context().push()

the error information notice the app.app_context(),i cannot solve it.
can anyone solute the problem?

0 Likes