from multiprocessing import Process
import os
def info(title):
print(title)
print('module name:', __name__)
print('parent process:', os.getppid())
print('process id:', os.getpid())
print(" ")
def f(name):
info(' 33[31;1mcalled from child process function f 33[0m')
print('hello', name)
if __name__ == '__main__':
info(' 33[32;1mmain process line 33[0m')
p = Process(target=f, args=('bob',))
p.start()
# p.join()
main process line
module name: __main__
parent process: 2728
process id: 25524
called from child process function f
module name: __mp_main__
parent process: 25524
process id: 14060
hello bob