Black Lives Matter. Please consider donating to Black Girls Code today.

Dash + Live MQTT Data

Hi everyone, I have been trying to figure this out for weeks and I can’t seem to find a solution.

I am using Dash to plot some positional data. The data is going to be received via an MQTT broker. My issue that I am running into is that the Dash server locks out all other processes (Understandable), but so does the loop for the MQTT loop that I am running to receive the data. I am trying to figure out how to integrate these two processes.

I have looked into the threading module for python and couldn’t get that to work. Any help would be greatly appreciated. I really need to get this figured out

You want to have a completely separate Python process read off the MQTT broker and put the data somewhere that Dash can read from. This is often achieved with something like Redis.

Would using this be the equivalent of writing to a file in script one and reading from it in script 2? I know it’s not that simple but that’s essentially the functionality that I need.

And If anyone is reading this, Do not try reading and writing from a file at the same time, very quickly, it will generate a queue of files :sweat_smile:

1 Like