python-multiprocessing

来源:互联网 发布:c free5电脑编程软件 编辑:程序博客网 时间:2024/05/02 19:32

import multiprocessing

pool = multiprocess.Pool( n ) # multi process

pool.map( func, input )

pool.close()  # there is no new process into pool after close

pool.join()  #wait all process done


from nmultiprocessing.dummy import Pool

pool = Pool( n )   # multi thread

pool.map( func, input )

pool.close()

pool.join()


note :  

def  __name__ == '__main__':   # should added


------reference-----------------

1. http://chriskiehl.com/article/parallelism-in-one-line/

2. https://dotblogs.com.tw/rickyteng/archive/2012/02/20/69635.aspx

0 0
原创粉丝点击