Python 3.x 如何在特定条件到达时停止python中的多个并行进程?

Python 3.x 如何在特定条件到达时停止python中的多个并行进程?,python-3.x,python-multiprocessing,concurrent.futures,Python 3.x,Python Multiprocessing,Concurrent.futures,在映射到输入列表的函数中出现特定条件时,如何停止python中的多个并行进程? 代码示例: from multiprocessing import Pool mylist = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] def squareprint(mylist): for elem in mylist: print(elem) with Pool(4) as p: print(p.map(squarepri

在映射到输入列表的函数中出现特定条件时,如何停止python中的多个并行进程? 代码示例:

from multiprocessing import Pool

mylist = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]

def squareprint(mylist):
    for elem in mylist:
        print(elem)

with Pool(4) as p:
    print(p.map(squareprint, mylist))
预期产出为:

# Expected output:
1
2
3 # and so on. Sequence of output doesn't matter.
现在,我想要的是,只要任何进程打印出“7”,无论何时打印,我希望所有进程立即停止。需要有一个中心实体,当看到“7”时,它会停止所有进程。 我该怎么做