Skip to content

RuntimeError: Working outside of application context. #3181

@arikfr

Description

@arikfr

After deploying v6-beta to demo.redash.io we started seeing this error, which we haven't before:
https://sentry.io/share/issue/08f84c11d6d04474b642b2d1435f9fb8/

By guessing what might be the cause of the issue I commented out the following code:

redash/redash/worker.py

Lines 85 to 90 in cfe12c5

@celery.on_after_configure.connect
def add_periodic_tasks(sender, **kwargs):
app = create_app()
periodic_tasks = getattr(app, 'periodic_tasks', {})
for params in periodic_tasks.values():
sender.add_periodic_task(**params)

Once I have the issue stopped happening. The reason I suspected this code was because we call create_app here for the second time during the initialization process of Celery.

I'm not sure why it causes it though or how to fix it (aside from removing this code). 🤔

@jezdez @emtwo If I'm not mistaken, you were running this code in your env for a long time now. You haven't seen this exception?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions