Running backend code continuously

Hello everyone…

My target is to run some backend code wrapped in the dash web app for visibility reasons (from browser).

Let’s say we have a console app that reports to command window the print() statements so we can view what is doing… I want to achieve something similar on dash app for monitoring purposes from a browser.

Also, the background tasks need to run continuously, like a normal python script with While True : … Even if the browser is closed and
on the web app is nobody connected. Same goes if 3 Clients are connected to dash app, only 1 time the back- end code needs to run, even with no clients at all, or with 3 Clients connected.

The only thing I could think of, is callback with interval element as input. Does this going to work if no client is connected?

Any comments highly appreciated.

hi @Bambos ,
I think you can register your background code as a service or daemon, and then check its status or start it in the callback.

As for real-time monitoring on the client side, please refer to this one of my tips series.

Hello @stu … what would be the difference if my back-end writing a text file locally with 20 lines (using first in first out) and then a dash app shows those lines in a text area ?

To my understanding would be the same, plus we might have the flexibility for saving the logs, or using the dash app to view multiple back-end logs from several codes that are running as service.
Or is there a benefit using the SSE that i’m not seeing ?

Thanks for your comment !

The difference is that, you like to send a message every few minutes, ask your friend on the stadium who scored another goal, or like to turn on the TV to watch live. And if the guy on the field has too many friends, he might go crazy.

I don’t know what flexibility you mean. Also, whether you wanna monitor a single log or multiple logs, it has nothing to do with data acquisition.

@stu thanks for your comment !

truth is my target is not to monitor the service that runs the code, is to have a print(‘example test’) functionality like the back-end provides. ( not logs a such)

if back-end working ok, is enough if you just watch the print () statements. Trying to wrap the existing back-end code in dash so we can have further functionality and better view from the users, we have this issue trying to solve.

i think now is more clear. any suggestions appreciated !