Python multiprocessing question.

Asked 2 years ago, Updated 2 years ago, 117 views

from multiprocessing import Process

def GO():
    print('Hi\n')

if __name__=='__main__':
    pr1 = Process(target=GO)
    pr2 = Process(target=GO)
    pr1.start()
    pr2.start()
    pr1.join()
    pr2.join()

I made it while looking at the multiprocessing example. Hi is not output at all. What's wrong?

Multi-threads work well, but only multiprocessing works like this.

I think it's a problem with my computer environment because it runs well with a code executor Is there a separate environment where multiprocessing is not possible?

python multiprocessing python3

2022-09-22 20:22

1 Answers

Not when running interactively, one-by-one.

You must save it as a file (.py) and run it.


2022-09-22 20:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.