Timeout in a plugin converted from webapp
Hi everyone,
We have a webapp which we converted to a plugin. We added a view specifically for models. However, in specific models (used kernels), starting view returns a timeout error after 60 seconds. We know that for those kernel based models, it takes some time to calculate everything on the plugin side. Is there any way to increase the timeout limit in general and even better, just for that plugin?
Thanks
Answers
-
Hi,
this timeout is not configurable, but it's only there for DSS to wait for the UI to be ready. It doesn't mean the webapp is killed if it doesn't respond in the allotted time.
For Python-based webapps, the usual workaround is to move the loading step to a Thread
import threading def load_my_things_in_some_global(): ... long stuff, puts result in some shared variable t = threading.Thread(target=load_my_things_in_some_global) t.start() def my_callback(...): if not my_things_are_ready: continue ... do stuff as usual
-
Thanks for your response. I am not familiar a lot with Threads, so I will probably misuse them. I would appreciate if you take another look here on my attempt:
def initDashboard(predictor, X_test, y_true): res = function_1(predictor._clf, X_test, y_true) db = function_2(res, arg_2=True) app.config.external_stylesheets = [dbc.themes.BOOTSTRAP] app.layout = db.layout() db.explainer_layout.register_callbacks(app) from threading import Thread t = Thread(target=initDashboard, args=(predictor, X_test, y_true,)) t.start()
What it takes a lot of time is the function_1 and function_2 which both are from the same external library. I guess it's not how Threads should be used, since I still get the timeout on the "Starting view" popup