msg '%sname:%spid:%swith lockprint(msg (label__name__os getpid())if __name__ ='__main__'lock lock(whoami('function call'lockp process(target=whoamiargs=('spawned child'lock) start( join(for in range( )process(target=whoamiargs=(('run process %si)lock)start(with lockprint('main process exit 'when runthis script first calls function directly and in-processthen launches call to that function in new process and waits for it to exitand finally spawns five function call processes in parallel in loop--all using an api identical to that of the threading thread model we studied earlier in this here' this script' output on windowsnotice how the five child processes spawned at the end of this script outlive their parentas is the usual case for processesc:\pp \system\processesmulti py function callname:__main__pid: spawned childname:__main__pid: main process exit run process name:__main__pid: run process name:__main__pid: run process name:__main__pid: run process name:__main__pid: run process name:__main__pid: just like the threading thread class we met earlierthe multiprocessing process object can either be passed target with arguments (as done hereor subclassed to redefine its run action method its start method invokes its run method in new processand the default run simply calls the passed-in target also like threadinga join method waits for child process exitand lock object is provided as one of handful of process synchronization toolsit' used here to ensure that prints don' overlap among processes on platforms where this might matter (it may not on windowsimplementation and usage rules technicallyto achieve its portabilitythis module currently works by selecting from platform-specific alternativeson unixit forks new child process and invokes the process object' run method in the new child parallel system tools