标签:utf8 ssi rgs RoCE foo lse main code pen
#!/usr/bin/env python2
# coding: utf8
import multiprocessing
def foo(h,context):
if h%2 == 0:
print (h)
else:
context.append(h)
if __name__ == "__main__":
## 设置共享list
con = multiprocessing.Manager().list()
## 设置进程池大小
p = multiprocessing.Pool(2)
for i in range(18):
# con = multiprocessing.Manager().list()
p.apply_async(foo,args=(i,con))
p.close()
p.join()
print con
Python多进程(multiprocessing)共享变量
标签:utf8 ssi rgs RoCE foo lse main code pen
原文地址:https://www.cnblogs.com/yes5144/p/11523530.html