Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! ✅Check out the new docs.

Show output of print function in interface?

I have a setup where a user clicks a button, and a long process starts running based on a function call from a callback. I.E.:

 def long_running_function():
    print("Output here.")
    print("Output here too.")
   @app.callback(Output('yada','yada'),
                     [Input('button','n_clicks')])
def run_process():
   long_running_function()

Is there a way to display the print calls from the long_running_function in the Dash interface in realtime so the user knows a process is happening, and what it is?

print would print the line to stdout. It won’t appear in the dash app.

You’d need some kind of server side store (like Redis) or implement a queue for users tasks. You send the messages from the long running tasks to the queue, a dcc.Interval callback fetch the messages from the queue and output them.