-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating thread in superset_config.py freezes app #29831
Comments
Hey there, @philipuvarov! I'm here to help you out with any issues you're facing. I can assist with bug fixes, answer any questions you have, and guide you on becoming a contributor. Let's work together to resolve any issues you're experiencing while we wait for a human maintainer. Creating a thread in To prevent this behavior, you should avoid running blocking operations directly in the configuration file. Instead, you can defer the execution of such operations to a later point in the application's lifecycle, such as after the application has fully initialized. Here is an example of how you can defer the execution of a blocking operation using a Flask application context: # superset_config.py
from threading import Thread
from flask import current_app
def my_background_task():
# Your long-running task here
pass
def start_background_task():
thread = Thread(target=my_background_task)
thread.start()
def init_app(app):
with app.app_context():
start_background_task()
# Add the init_app function to the list of functions to be called when the app is initialized
APP_INITIALIZATION = [init_app] In this example, the |
^ this does not fly unfortunately. |
Bug description
Hey! This is probably on weirder side of things, but I wanted to create a job in
superset_config.py
to update some things and i have noticed that even though I am doing thing in a separate thread, it still hangs the whole app.So basically if I add something like this in
superset_config.py
In
superset_config.py
add:the app freezes until
sleep
finishes. Is this an expected behavior?How to reproduce the bug
In
superset_config.py
add:App becomes unresponsive until
sleep
finishes even though it is executed on another thread.Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: