Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬Register for the Oct 27 webinar.

Separate extensive calculation thread, one for all users

Hi, I am trying to setup a protoype of a webapp with dash. On the dashboard, the results of some extensive calculation are shown which can be used by all users and the results for that are read by the callbacks from files or webhooks. There should be one additional thread running each 30s in the background doing all the calculations and preparing them for presentation. This thread should be done only once for all users. Currenty this thread is linked to web-component which callback is called every 30s, but then for every user.
How can this be done better? This calcuation should be inside the python dash server app, not a separate one. Thus, maybe starting a separate thread when starting the app_server, which never ends? I think the “lock” mechanism of thread in dash does not work here, because it only locks the thread for oneuser, not checking if active in other users?
Any ideas would be very welcome!! many thanks!!

Is the long calculation completely decoupled from the application? In other words, does it depend on changes made in the application directly? It looks like the callbacks are consuming output files from it, so I wonder if this long calculation could run in a different process.

As a side note, you could take a look on the long_callback functionality pre-released in Dash 2.0:

https://dash.plotly.com/long-callbacks

There is also a feedback thread that you might find interesting to follow.