0

I was working on a larger piece of code and I kept getting an error when the program just seemed to end without doing anything. I narrowed down the problem and reproduced it below. As far as I understand the code should print the sentence and it seems to work on other online IDE's while failing on mine. Feel like I'm missing something super simple.

Failing On: IDLE Python 3.8.3 32-bit from python.org

Works On: onlinegdb.com

Code:

import multiprocessing

def x():
    print("This is x func")

if __name__ == '__main__':
    multiprocessing.freeze_support()
    p = multiprocessing.Process(target=x)
    p.start()
    p.join()

Output:

>>> 
  • 1
    I think you should try running this outside of IDLE, maybe on the terminal using the command `python3 ` since [IDLE doesn't work well with multiprocessing](https://stackoverflow.com/questions/12828338/python-3-2-multiprocessing-process-not-running-target-function) – tax evader Apr 10 '21 at 05:20

1 Answers1

0

I think the issue is IDLE just doesn't output stuff from stuff outside the main process. Need to use consoles which would output everything from the main and all other processes. Reference : Python multiprocessing example not working