Python 多线程模块在没有错误消息的情况下崩溃

Python multithreading module crashing without an error message

当我 运行 我的代码时,它只是直接没有做任何事情。 python 解释器只是坐在那里挂起,直到我关闭它。我什至没有收到错误消息。是什么原因造成的?这是我的代码:

import multiprocessing

def worker(x):
    return x

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

什么都不打印。它只是停止了。我该如何开始解决这个问题?

虽然我不确定为什么这对您不起作用,但我的系统也遇到过类似的问题。我通过使用 multiprocessing.Pipe 克服了它,你可以在这里找到 https://docs.python.org/3/library/multiprocessing.html