Many moons later and I’m back to a need for this! Sorry for the delay, and I’m still finding this to be an issue. I think the issue lies in spinning up something else that is also watching/reacting/etc. from Dash. I think this post is similar and my need, I think, is bigger than just writing a status to a file.
I’m trying to make a user interface for some Robot Operating System (ROS) code. ROS enables many nodes to co-exist and communicate on things called topics. An analogy might be something like a webserver that can do GET/POST. I’ve been hoping to combine these things into one, but am having a tough time.
So imagine you have some other library and need to create an object listening/publishing on some other port… maybe:
foo = Server(port)
foo.start()
In addition, perhaps periodically you do foo.publish()
.
What I’m finding is if I initialize this up with app = dash.Dash(__name__)
, it recreates with any page refresh, so I get errors due to the node already existing. I can put some checks in a function like your example, but I don’t know how to pass foo
around to run foo.publish()
.
Do you have recommendations of where to create some object you need to interact with, (assuming that this server analogy makes sense and is possible with Dash)?
Also, for a secondary process, how does one kill off everything when you kill Dash?