How to update elements (Output) from a thread/task, without input?

In a GUI it is often the case that a user action triggers a process/thread to run which may want to update the page in some way: update the plotly graph shown, show some updated value in a HTML text element, show an updated status message.

All this happens without any “Input” originating in the GUI, but should be possible to be done by the running process/thread or some intermediary.

Is this possible in Dash at all?

I originally decided to use Dash for my purposes because of the ease of how to include existing plotly graphs in the web page, but the whole callback architecture seems to be so limited that Dash is probably the wrong library for me.

Hi @johann.petrak,

Do you mean something like the interval component? I guess not, most likely something like external workers that are triggered on some time interval or some event-based system. I think celery might of interest to you if you are looking for more advanced scheduled tasks

Sorry, no, I know how to do the multiprocessing/multithreading stuff.

The problem is, that I do not see any way for how those threads would be able to update the web page or the figure I show in the web page if this needs to be done via the “ouput” of a callback: since a callback HAS to have an input, a message to be shown on the web page can not just originate from a thread - it needs an input, but which? There is none!

Is there any way to accomplish this? If not I think it is an even bigger problem than that other problem I encountered a while ago, that two callbacks cannot write to the same output.

Is there some other way to show an interactive plotly graph (one where information from the interaction with the graph can come back to a running python program) in a GUI where it would also be possible to do those other things, i.e. update information from threads, update the figure from threads etc. ?

@johann.petrak Yes, I see your point now., but unfortunately I don’t have an answer :frowning:. I think this already an advanced use case so I think it’s best to loop in @adamschroeder to confirm whether dash plotly is the right fit for your requirement.

Hello @johann.petrak,

There are several ways that you can check for updates, the main way would be to use n_intervals.

Ideally, this would query data from where the processes are writing to.

The above process would be inside of vanilla Dash.

You could also use web sockets to send info to dash directly, in which case they just respond to receiving a message.

You could potentially work it out that your process sends data to a db that this process works, or maybe send a post request to the web socket server that queues up data to your dash app.