如果一定要在进程间共享数据,multiprocessing模块提供了一些方法。... print d
print l
....:
{0.25: None, 1: '1', '2': 2}
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
5.使用一组工作进程...使用Pool对象会创建一组worker进程
from multiprocessing import Pool, TimeoutErrorimport timeimport osdef f(x):
...Pool对象的函数只能是创建它的进程可以使用。...multiprocessing模块的提供的函数需要子进程可以导入__main__模块
参考文档:
https://docs.python.org/2/library/multiprocessing.html