code

import multiprocessing
import time

def foo():
    print ('Starting function')
    time.sleep(0.1)
    print ('Finished function')
if __name__ == '__main__':
    p = multiprocessing.Process(target=foo)
    print ('Process before execution:', p, p.is_alive())
    p.start()
    print ('Process running:', p, p.is_alive())
    p.terminate()
    print ('Process terminated:', p, p.is_alive())
    p.join()
    print ('Process joined:', p, p.is_alive())
    print ('Process exit code:', p.exitcode)

 

 

 

 

 

 

 

 

 

 

 

相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2021-11-29
  • 2021-12-12
  • 2021-08-31
  • 2021-10-06
  • 2021-10-02
猜你喜欢
  • 2021-10-03
相关资源
相似解决方案