0

A GUI I've created uses multiprocess.Process function call to finish work quicker by using more than one process.

w1 = multiprocessing.Process(target = _process_worker.start)

When I run the GUI as a python script gui.py any I click the button that starts the workers everything works great, work is done quicker and no issues.

When I compile the python program into a window applications (using pyinstaller), clicking the same button causes the GUI to start multiple instances of itself; that is everytime the multiprocess call is made, the gui starts another gui application.

pyinstaller.ex --onefile --windowed --icon=guiicon.ico gui.py

Does anyone know how I can have the process just do the work instead of opening multiple instances of itself? Why is it doing this in the first place?

tyleax
  • 1,556
  • 2
  • 17
  • 45

1 Answers1

4

In using the multiprocessing module, you must call

multiprocessing.freeze_support()

straight after the if __name__ == '__main__': line of the main module.

Please read the Python library manual about multiprocessing.freeze_support for more information.

Reference: https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing

tyleax
  • 1,556
  • 2
  • 17
  • 45