You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "joserocha (via GitHub)" <gi...@apache.org> on 2026/03/10 18:12:38 UTC
[I] query_timeout - RuntimeError: Working outside of application context [superset]
joserocha opened a new issue, #38564:
URL: https://github.com/apache/superset/issues/38564
### Bug description
I deployed a new Superset application in my Kubernetes dev environment, but when the pods related to async throw the error below:
`Starting Celery worker...
Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
2026-03-10 17:59:22,392:INFO:alembic.runtime.migration:Context impl PostgresqlImpl.
2026-03-10 17:59:22,393:INFO:alembic.runtime.migration:Will assume transactional DDL.
2026-03-10 17:59:23,367:INFO:superset.app:Syncing configuration to database...
2026-03-10 17:59:23,395:INFO:superset.app:Configuration sync to database completed successfully
Traceback (most recent call last):
File "/app/.venv/bin/celery", line 10, in <module>
sys.exit(main())
File "/app/.venv/lib/python3.10/site-packages/celery/__main__.py", line 15, in main
sys.exit(_main())
File "/app/.venv/lib/python3.10/site-packages/celery/bin/celery.py", line 231, in main
return celery(auto_envvar_prefix="CELERY")
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1442, in __call__
return self.main(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1363, in main
rv = self.invoke(ctx)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1830, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 794, in invoke
return callback(*args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/click/decorators.py", line 34, in new_func
return f(get_current_context(), *args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/celery/bin/base.py", line 135, in caller
return f(ctx, *args, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/celery/bin/worker.py", line 348, in worker
worker = app.Worker(
File "/app/.venv/lib/python3.10/site-packages/celery/worker/worker.py", line 94, in __init__
self.app.loader.init_worker()
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 110, in init_worker
self.import_default_modules()
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in import_default_modules
return [self.import_task_module(m) for m in self.default_modules]
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 105, in <listcomp>
return [self.import_task_module(m) for m in self.default_modules]
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 85, in import_task_module
return self.import_from_cwd(module)
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 91, in import_from_cwd
return import_from_cwd(
File "/app/.venv/lib/python3.10/site-packages/celery/utils/imports.py", line 109, in import_from_cwd
return imp(module, package=package)
File "/app/.venv/lib/python3.10/site-packages/celery/loaders/base.py", line 88, in import_module
return importlib.import_module(module, package=package)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/app/superset/tasks/async_queries.py", line 49, in <module>
query_timeout = current_app.config[
File "/app/.venv/lib/python3.10/site-packages/werkzeug/local.py", line 318, in __get__
obj = instance._get_current_object()
File "/app/.venv/lib/python3.10/site-packages/werkzeug/local.py", line 519, in _get_current_object
raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.`
I'm using the Superset 6.0.1 rc1.
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] query_timeout - RuntimeError: Working outside of application context [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #38564:
URL: https://github.com/apache/superset/issues/38564#issuecomment-4033472731
<!-- Answer -->
This is a known bug in Superset v6 where `query_timeout` is accessed at [module level in async_queries.py (lines 44-46)](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py#L44-L46):
```python
query_timeout = current_app.config[
"SQLLAB_ASYNC_TIME_LIMIT_SEC"
]
```
When Celery imports this module at startup, there's no active Flask application context, causing the `RuntimeError`.
This was identified as a systemic issue in [PR #34345](https://github.com/apache/superset/pull/34345) and has been reported in [#36892](https://github.com/apache/superset/issues/36892). The fix involves moving configuration access from module scope into functions where app context is guaranteed.
**Workaround options:**
1. Use Superset v5.0.0 instead, as [v6 has multiple production-readiness issues](https://github.com/apache/superset/issues/37075)
2. Patch the file locally to move `query_timeout` access inside the task functions that need it
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1ad48554-ae54
-438f-9255-e52a864fe877?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report ๐](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/1ad48554-ae54-438f-9255-e52a864fe877?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=This%20is%20a%20known%20bug%20in%20Superset%20v6%20where%20%60query_timeout%60%20is%20accessed%20at%20%5Bmodule%20level%20in%20async_queries.py%20%28lines%2044-46%29%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py%23L44-L46%29%3A%0A%0A%60%60%60python%0Aquery_timeout%20%3D%20current_app.config%5B%0A%20%20%20%20%22SQLLAB_ASYNC_TIME_LIMIT_SEC%22%0A%5D%0A%60%60%60%0A%0AWhen%20Celery%20imports%20this%20module%20at%20startup%2C%20there%27s%20no%20active%20Flask%20application%20context%2C%20causing%20the%20%60RuntimeError%60.%0A%0AThis%20was%20identified%20as%20a%20systemic%20issue%20in%20%5BPR%20%2334345%5D%2
8https%3A//github.com/apache/superset/pull/34345%29%20and%20has%20been%20reported%20in%20%5B%2336892%5D%28https%3A//github.com/apache/superset/issues/36892%29.%20The%20fix%20involves%20moving%20configuration%20access%20from%20module%20scope%20into%20functions%20where%20app%20context%20is%20guaranteed.%0A%0A%2A%2AWorkaround%20options%3A%2A%2A%0A1.%20Use%20Superset%20v5.0.0%20instead%2C%20as%20%5Bv6%20has%20multiple%20production-readiness%20issues%5D%28https%3A//github.com/apache/superset/issues/37075%29%0A2.%20Patch%20the%20file%20locally%20to%20move%20%60query_timeout%60%20access%20inside%20the%20task%20functions%20that%20need%20it) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20m
e%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38564)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] query_timeout - RuntimeError: Working outside of application context [superset]
Posted by "joserocha (via GitHub)" <gi...@apache.org>.
joserocha commented on issue #38564:
URL: https://github.com/apache/superset/issues/38564#issuecomment-4033833982
It worked !!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] query_timeout - RuntimeError: Working outside of application context [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #38564:
URL: https://github.com/apache/superset/issues/38564#issuecomment-4033569399
<!-- Answer -->
Here's how to patch `superset/tasks/async_queries.py`:
**Step 1:** Remove [lines 44-46](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py#L44-L46) (the module-level `query_timeout` variable):
```python
# DELETE THESE LINES:
query_timeout = current_app.config[
"SQLLAB_ASYNC_TIME_LIMIT_SEC"
] # TODO: new config key
```
**Step 2:** Update the task decorators to remove `soft_time_limit=query_timeout`:
At [line 82](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py#L82):
```python
# Change FROM:
@celery_app.task(name="load_chart_data_into_cache", soft_time_limit=query_timeout)
# Change TO:
@celery_app.task(name="load_chart_data_into_cache")
```
At [line 116](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py#L116):
```python
# Change FROM:
@celery_app.task(name="load_explore_json_into_cache", soft_time_limit=query_timeout)
# Change TO:
@celery_app.task(name="load_explore_json_into_cache")
```
**Note:** This removes the soft time limit functionality for these tasks. If you need to preserve the timeout behavior, you can set `CELERYD_TASK_SOFT_TIME_LIMIT` globally in your Celery config, or add the timeout logic inside each task function using:
```python
load_chart_data_into_cache.request.time_limits = (
None,
current_app.config["SQLLAB_ASYNC_TIME_LIMIT_SEC"]
)
```
The key issue is that `current_app.config` can't be accessed at module import timeโit must be inside a function where Flask's application context exists.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/21658fd3-7f92
-4597-be5f-51bbb7967efb?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report ๐](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/21658fd3-7f92-4597-be5f-51bbb7967efb?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=Here%27s%20how%20to%20patch%20%60superset/tasks/async_queries.py%60%3A%0A%0A%2A%2AStep%201%3A%2A%2A%20Remove%20%5Blines%2044-46%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py%23L44-L46%29%20%28the%20module-level%20%60query_timeout%60%20variable%29%3A%0A%60%60%60python%0A%23%20DELETE%20THESE%20LINES%3A%0Aquery_timeout%20%3D%20current_app.config%5B%0A%20%20%20%20%22SQLLAB_ASYNC_TIME_LIMIT_SEC%22%0A%5D%20%20%23%20TODO%3A%20new%20config%20key%0A%60%60%60%0A%0A%2A%2AStep%202%3A%2A%2A%20Update%20the%20task%20decorators%20to%20remove%20%60soft_time_limit%3Dquery_timeout%60%3A%0A%0AAt%20%5Bline%2082%5D%28https
%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py%23L82%29%3A%0A%60%60%60python%0A%23%20Change%20FROM%3A%0A%40celery_app.task%28name%3D%22load_chart_data_into_cache%22%2C%20soft_time_limit%3Dquery_timeout%29%0A%0A%23%20Change%20TO%3A%0A%40celery_app.task%28name%3D%22load_chart_data_into_cache%22%29%0A%60%60%60%0A%0AAt%20%5Bline%20116%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/tasks/async_queries.py%23L116%29%3A%0A%60%60%60python%0A%23%20Change%20FROM%3A%0A%40celery_app.task%28name%3D%22load_explore_json_into_cache%22%2C%20soft_time_limit%3Dquery_timeout%29%0A%0A%23%20Change%20TO%3A%0A%40celery_app.task%28name%3D%22load_explore_json_into_cache%22%29%0A%60%60%60%0A%0A%2A%2ANote%3A%2A%2A%20This%20removes%20the%20soft%20time%20limit%20functionality%20for%20these%20tasks.%20If%20you%20need%20to%20preserve%20the%20timeout%20behavior%2C%20you%20can%20set%20%60CELERYD_TASK_SOFT_
TIME_LIMIT%60%20globally%20in%20your%20Celery%20config%2C%20or%20add%20the%20timeout%20logic%20inside%20each%20task%20function%20using%3A%0A%60%60%60python%0Aload_chart_data_into_cache.request.time_limits%20%3D%20%28%0A%20%20%20%20None%2C%0A%20%20%20%20current_app.config%5B%22SQLLAB_ASYNC_TIME_LIMIT_SEC%22%5D%0A%29%0A%60%60%60%0A%0AThe%20key%20issue%20is%20that%20%60current_app.config%60%20can%27t%20be%20accessed%20at%20module%20import%20time%E2%80%94it%20must%20be%20inside%20a%20function%20where%20Flask%27s%20application%20context%20exists.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38564)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] query_timeout - RuntimeError: Working outside of application context [superset]
Posted by "joserocha (via GitHub)" <gi...@apache.org>.
joserocha commented on issue #38564:
URL: https://github.com/apache/superset/issues/38564#issuecomment-4033523683
Hello @dosu
Downgrade to v5.0.0 is not a possibility right now.
How can I achieve the workaround number 2 ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [I] query_timeout - RuntimeError: Working outside of application context [superset]
Posted by "joserocha (via GitHub)" <gi...@apache.org>.
joserocha closed issue #38564: query_timeout - RuntimeError: Working outside of application context
URL: https://github.com/apache/superset/issues/38564
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org