Search code examples
python-3.xpython-multiprocessingpython-multithreading

Python multithreading module crashing without an error message


When I run my code, it just straight up doesn't do anything. The python interpreter just sits there and hangs until I close it. I don't even get an error message. What could be causing this? This is my code:

import multiprocessing

def worker(x):
    return x

pool = multiprocessing.Pool()
print(pool.map(worker, range(10)))
print (1)

Nothing is ever printed. It simply stops. How do I even begin to fix this?


Solution

  • While I am unsure why this doesn't work for you, I had a similar problem on my system. I overcame it by using multiprocessing.Pipe, which you can find here https://docs.python.org/3/library/multiprocessing.html