Multiprocessing is not working when PyQt widgets , DataProbe and DicomLib are used.

I am running an algorithm in a python script using command line with --python-script command, which has a custom button created in slicer UI, when I trigger this button , algorithm will start, which is using multiprocessing and creating spawn type context object and runs several processes. When I did that I am getting error as below.

When I removed the places wherever I am using QtWidgets, DataProbe and DicomLib then the python script is running multiprocessing and algorithm successfully. These libraries are required for my complete functionality, so I can’t remove them. Please help me here.

@lassoan Please help me out here, its kinda urgent.

Most objects are only usable on a single thread. Therefore, you usually cannot simply run the same code in a processing thread that works on the main thread.

You can only run processing in the worker threads and you must not access GUI widgets and application objects. See GitHub - pieper/SlicerParallelProcessing: Slicer modules for running subprocesses to operate on data in parallel extension for examples of how you can implement parallel processing in Python in Slicer.