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>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](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)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](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.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to