美文网首页
multiprocessing

multiprocessing

作者: 木一乎 | 来源:发表于2018-12-07 11:37 被阅读0次
    def task(pid):
        # do something
        return result
    
    def main():
        multiprocessing.freeze_support()
        pool = multiprocessing.Pool()
        ntasks = 200;
        results = []
        for i in xrange(0, ntasks):
            result = pool.apply_async(task, args=(i,))
            results.append(result)
        pool.close()
        pool.join()
    
    for result in results:
        print(result.get())
    

    相关文章

      网友评论

          本文标题:multiprocessing

          本文链接:https://www.haomeiwen.com/subject/dwfthqtx.html