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

Python 进程

时间:2017-10-28 19:01:10      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:print   import   reading   ppi   join   hello   fun   _id   mod   

import multiprocessing,threading
import time
import os

def threading_run():
print("线程ID",threading.get_ident())
t=threading.Thread(target=threading_run)

def info(title):
print(title)
print(‘module name:‘,__name__)
print("parent process:",os.getppid())
print("process id:",os.getpid())

def f(name):
time.sleep(1)
info("\033[31;1mfunction f\033[m")
print("Hello !",name)
t.start()

if __name__ == ‘__main__‘:
info(‘\033[32;1m main process line \033[0m]‘)
for i in range(5):
p = multiprocessing.Process(target=f,args=("bob"+ str(i),))
p.start()
p.join()

Python 进程

标签:print   import   reading   ppi   join   hello   fun   _id   mod   

原文地址:http://www.cnblogs.com/xiesongyou/p/7747520.html

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