[英]python multiprocess: parent process can not exit
I want parent process exit, and child process can still run.我希望父进程退出,子进程仍然可以运行。
When i run code, parent process can not exit.当我运行代码时,父进程无法退出。 I use
return
to exit parent process.我使用
return
退出父进程。 And child process can still run.子进程仍然可以运行。
Why did parent process not exit?为什么父进程没有退出?
System: centos7系统:centos7
Python version: 3.6 Python 版本:3.6
import os
import time
from multiprocessing import Process
def run_process():
count = 0
while True:
print('it is son', os.getpid())
time.sleep(3)
count += 1
if count >= 10:
return
def main():
t = Process(target=run_process)
t.start()
print('it is father', os.getpid())
return
if __name__ == '__main__':
main()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.