pieper / SlicerParallelProcessing

Slicer modules for running subprocesses to operate on data in parallel
Other
11 stars 5 forks source link

GUI frozen while running multiple process ? #6

Closed manhntm3 closed 4 years ago

manhntm3 commented 4 years ago

If I put a time.sleep(5) in a processing input output function like this:

def prepareProcessInput(self):
    input = {}
    input['array'] = slicer.util.arrayFromVolume(self.volumeNode)
    input['spacing'] = self.volumeNode.GetSpacing()
    input['dimensions'] = self.volumeNode.GetImageData().GetDimensions()
    input['type'] = self.volumeNode.GetImageData().GetScalarType()
    input['radius'] = self.radius
    time.sleep(5)
    return pickle.dumps(input)

When it performs the test, the GUI is frozen and inaccessible. Is there any way to change GUI when waiting for processing in background ?

pieper commented 4 years ago

The prepare step happens in the main thread of the Slicer process, so yes, this will freeze the application. You need to put code like that in your ProcessScript, which runs in a different OS process from the main application.

For example:

https://github.com/pieper/SlicerProcesses/blob/master/Processes/Resources/ProcessScripts/modelFilter.slicer.py