fork download
  1. from multiprocessing import Process
  2. import os
  3.  
  4. def run_proc(name):
  5. print('run child process %s (%s)...' % (name, os.getpid()))
  6.  
  7. if __name__=='__main__':
  8. print('parent process %s:' % os.getpid())
  9. p=Process(target=run_proc, args=('test',))
  10. print('child process will start..')
  11. p.start()
  12. p.join()
  13. print('child process ends.')
  14. # your code goes here
Success #stdin #stdout 0.06s 11120KB
stdin
Standard input is empty
stdout
parent process 3563019:
child process will start..
run child process test (3563023)...
child process ends.