Below "main.py" Python program works ok when I run it using python3 (v3.8.10) command on Ubuntu v20.04.4 LTS.
import multiprocessing as mp
def P3_sm():
print("P3 created.")
print("P3 destroyed.")
def P2_sm():
print("P2 created.")
P3 = mp.Process(target=P3_sm)
P3.start()
P3.join()
print("P2 destroyed.")
if __name__ == '__main__':
mp.freeze_support() # ADDING THIS LINE DID NOT HELP!
print("P1 created.")
P2 = mp.Process(target=P2_sm)
P2.start()
P2.join()
print("P1 destroyed.")
I built an exe using auto-py-to-exe v2.33.0 which formed below command and generated exe. pyinstaller --nonconfirm --onefile --windowed "/home/max/test/main.py"
When I run this exe it only prints below 2 lines and never terminates the program. Any help is highly appreciated!
P1 created.
P2 created.
When I run the exe file on Ubuntu platform I'm expecting it to print below 6 lines and terminate the program as it does when I run the main.py file using python3 command.
P1 created.
P2 created.
P3 created.
P3 destroyed.
P2 destroyed.
P1 destroyed.
Please note I added below line in my program and that did not help to resolve the problem on Ubuntu platform.
mp.freeze_support()