标签:func UNC for form pid pen 进程池 code tip
import os
from multiprocessing import Pool
demo = ‘this is a test‘
def func():
with open(‘text.txt‘, ‘w‘) as f:
f.write(demo)
print(‘process {} write success‘.format(os.getpid()))
if __name__ == ‘__main__‘:
p = Pool(5)
for i in range(100):
# 异步,可以设置回调、函数
p1 = p.apply_async(func)
p.close()
p.join()
标签:func UNC for form pid pen 进程池 code tip
原文地址:https://www.cnblogs.com/hui-code/p/12735185.html