I recently dabbled with multiprocessing
in one of my python projects.
I would run my script in my terminal and everything would run flawlessly. However, when I turned the .py
script into a .exe
using pyinstaller
it wouldn't work anymore.
I've narrowed it down to the issue being the Manager()
method.
Consider the following piece of code:
from multiprocessing import Manager
if __name__ == '__main__':
print("Starting")
manager = Manager()
print("Worked")
Running the script as a .py
file outputs:
> Starting
> Worked
After converting to a .exe
the script outputs Starting
continuously:
> Starting
> Starting
> Starting
etc...
I managed to snatch this error code after performing a keyboardinterrupt on the running code if any help.
Please let me know if you guys encounter the same issue, or have any idea how to fix this. Have a great weekend <3
Thank you so much g.d.d.c
all I had to do was
import an extra method
and add an extra command
The code now looks like this:
from multiprocessing import Manager, freeze_support
if __name__ == '__main__':
freeze_support()
print("Starting")
manager = Manager()
print("Worked")
<kite.com/python/docs/multiprocessing.freeze_support>