码迷,mamicode.com
首页 > 编程语言 > 详细

[Python]Running multiprocessing

时间:2020-01-27 10:57:11      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:ESS   port   targe   def   tip   struct   star   imp   exiting   

import multiprocessing as mp
import time

def name_and_time(name,num):
    print(f"Hello {name}, current time is {time.time()} ({num})")
    print(Sleeping for 2 seconds ...)
    time.sleep(2)
    print("After sleeping ... exiting function")


if __name__ == __main__:
    process_list = list()

    for i in range(100):
        process = mp.Process(target=name_and_time,args=(Andrei,i))
        process_list.append(process)

    for p in process_list:
        p.start()

    for p in process_list:
        p.join()
        
    print(Other instructions of the main module....)
    print(End of Script)

 

[Python]Running multiprocessing

标签:ESS   port   targe   def   tip   struct   star   imp   exiting   

原文地址:https://www.cnblogs.com/jbite9057/p/12235503.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!