Threading in a ParaView Python plugin (Linux)

Hello,

I was trying to use the threading library in a python plugin, but it doesn’t work exactly as I want it to.

What I want is to create a thread that is always running continuously in the background, but currently I can’t get it to work. As an example and for simplicity, I’ll put a dummy case of a source module. With this code:

@smproxy.source(name="StorageDictReader", label="EnricSosa - StorageDict Reader")
class StorageDictReader(VTKPythonAlgorithmBase):
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self, nInputPorts=0, nOutputPorts=1, outputType='vtkPolyData')
        [...]
        self.dummy_thread = threading.Thread(target=self._dummy_thread_function, args=())
        self.dummy_thread.start()

    def _dummy_thread_function(self):
        print("[DUMMY THREAD] I'M A NEW DUMMY THREAD", flush=True)
        i = 1
        while True:
            print("[DUMMY THREAD] sleeping", i, "seconds", flush=True)
            sleep(1)
            i += 1

When I load the plugin and put the module in the pipeline, I see a print and that’s it. When I request “RequestData”, like pressing the “Apply” button or the “Next Frame” button for the next timestep, I also see prints from the thread, but it only runs for the time it takes for the plugin to “RequestData”. What I want is that the thread runs all the time, from the moment it starts with “.start()”. I don’t know if this is possible.

I hope I was understood. For additional information that might be useful, I am using Paraview 5.11.0 in a linux client-server environment. I have no rights to install and configure ParaView on the server. I have searched and saw this Topic, but it does not solve exactly what I want.

Best regards,
Thanks in advance