有时我需要对没有参数的函数使用多处理。我希望我能做些什么:
from multiprocessing import Pool
def f(): # no argument
return 1
# TypeError: f() takes no arguments (1 given)
print Pool(2).map(f, range(10))
我可以做Process(target=f, args=())
,但我更喜欢map
/imap
/imap_unordered
的语法。有办法吗?
Tags:
目前没有回答
相关问题 更多 >
编程相关推荐