Difficult-Rocket/tests/performance_check/process_check.py

40 lines
680 B
Python
Raw Normal View History

2021-08-13 12:25:29 +08:00
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
github: @shenjackyuanjie
"""
import os
2021-09-05 00:50:05 +08:00
from multiprocessing import Process
2021-08-13 12:25:29 +08:00
def testsss(a):
print(os.getpid())
print(os.getppid())
if __name__ == '__main__':
print(os.getpid())
print(os.getppid())
pro = Process(target=testsss, args=('a',))
pro.start()
pro.join()
def info(title):
print(title)
print('module name:', __name__)
print('parent process:', os.getppid())
print('process id:', os.getpid())
def f(name):
info('function f')
print('hello', name)
if __name__ == '__main__':
info('main line')
p = Process(target=f, args=('bob',))
p.start()
p.join()