from multiprocessing import Processimport timedef func(): while True: time.sleep(0.2) print('我还活着')def func2(): print('in func2 start') time.sleep(8) print('in func2 finished')if __name__ == '__main__': p = Process(target=func) p.daemon = True p.start() Process(target=func2).start() i = 1 while i<6: print('我是socket server') time.sleep(1) i += 1# 守护进程会随着主进程的代码执行完毕而结束