output = mp.Queue()
def rand_string(length, output):
output.put(length)
if __name__ == "__main__":
# Setup a list of processes that we want to run
processes = [mp.Process(target=rand_string, args=(x, output)) for x in range(4)]
# Run processes
for p in processes:
p.start()
# Exit the completed processes
for p in processes:
p.join()
# Get process results from the output queue
results = [output.get() for p in processes]
print(results)
这是一段官方文档中代码,只是稍加改造而已,我在pycharm中运行正常,但是到了jupyter中,却没有反应,点了运行,然后代码框前面的序号变成星号,就没有然后了,也不报错,一只就这样。请问各位大神,有知道的吗?不仅如此,很多涉及到多进程的例子,我在pycharm下跑的通,到了jupyter下,就没反应。