Seedlink infinite loop

Hi. I create a seedlink client in a thread but Could you suggest How do I can pass the trace from the thread to the main program thread where the GUI is implemented? I just want the real time data but I cannot figure out how to get the data from the thread, since doing this in the same main thread stuck the GUI due to the infinite loop.

Could you please help me with this, any design idea or suggestion?

Hi @ivmoma,

The way I do this is to have a class that runs the seedlink client, and a method on that class that allows you to access the data in another thread. If you want to see an example of how I implement acquisition and subsequent plotting and processing of real-time data then check out RT-EQcorrscan - in particular, the Streamer abstract base-class implements the methods I mentioned. It has a lot of additional things that you probably don’t need, but the key things are the get_stream method and associated locks and buffers. It is worth pointing out that as soon as you get into multi-threaded programming locks become important, and life gets a lot more complicated!

I can’t help with any more specific details without seeing some code and understanding what you are trying to do. If you are just trying to plot data from a seedlink client then this project might be appropriate, but it hasn’t been updated for a while.

Thank you so much for your response and help. I would like to create an app to plot SSAM in realtime using a gui with pyqt5. It’s simple but it was a little bit confusing to me to try to find out a way to get the trace from the infinite loop which locked my app. Reading code from others seems to be that everything is almost done without gui’s and for plots many use obspy native functions available. I have not so much code written, since I was testing the QRunnable and QThreadPool classes and a way to adapt this to the loop. Have you ever use this classes? I will keep you in touch I really appreciate your help!!! Thanks!!!


No I have not used those classes - I do most of my plotting of real-time data using either bokeh or matplotlib directly. Using those libraries means not having to worry about the plotting event loop, which adds more complication.

The lock you run in to is probably because you are trying to access the data that the client is updating - you cannot access the same data from multiple threads at the same time. Like I said, the get_stream method and associated locks (using multhreading.Lock) make data access safe in the Streamer ABC above.

@ivmoma you can also have a look at, it runs three threads. Main one for the GUI and then two more for the continuous seedlink data acquisition and one for fetching events every now and then. In my opinion a good minimal example.

Hi, Thank you so much for your help!