process name and is_alive
is_alive (the child immediately to see whether the results of survival)
from multiprocessing import Process
import time
def foo():
print('进程 start')
time.sleep(2)
print('进程 end')
if __name__ == '__main__':
p=Process(target=foo)
p.start()
print(p.is_alive())#True
time.sleep(5)
print(p.is_alive()) # 代码运行完了就算死了 False
print('主')
name (see sub-process name)
Do not set the process name of the default settings will give the child the name of Process-1
from multiprocessing import Process,current_process
import time
def foo():
print('进程 start')
print('-------',current_process().name)
time.sleep(2)
print('进程 end')
if __name__ == '__main__':
p=Process(target=foo)
p2=Process(target=foo)
p3=Process(target=foo,name='rocky')
p.start()
p2.start()
p3.start()
print(p.name)
print(p2.name)
print(p3.name)
print('主')