我做了一个非常简单的例子,看看starmap是否可以同时调用add_func和iter_func同时产生新的参数,但不幸的是,它没有工作
from functools import partial
from itertools import repeat
from multiprocessing import Pool, freeze_support
import time
def add_func(a, b):
print(a,b)
return a + b
def iter_func():
i = 0
while True:
print("yeild")
yield i,i+1
i+=1
time.sleep(1)
def main():
with Pool() as pool:
L = pool.starmap(add_func, iter_func())
print(L)
freeze_support()
main()