嵌套循环多进程

from multiprocessing import Pool
import logging

def log_conf():
    logging.basicConfig(
        level=logging.DEBUG,
        format='{} {:<12}: {}'.format(('%(asctime)s'),('[%(levelname)s]'),('%(message)s')),
        filename='app1.log'
    )

def task(i,a):
    log_conf()
    result='task {}的循环数{}'.format(i,a)
    logging.info(result)

if __name__=='__main__':
    log_conf()
    # logging.info('info')
    p=Pool(4)
    for i in range(10):
        for a in range(10,20):
            p.apply_async(task,args=(i,a))
    p.close()
    p.join()
    print('主进程结束')

  

posted @ 2021-01-12 21:32  魔阳工  阅读(196)  评论(0编辑  收藏  举报