您可以通过以下方式打开日志记录,从而更清楚地了解事件的顺序
import multiprocessing as mplogger = mp.log_to_stderr(logging.INFO)
在其他import语句之后。然后您的程序将产生如下内容:
[INFO/Process-1] child process calling self.run()[INFO/MainProcess] process shutting downProcess-1 starting...beep...[INFO/Process-2] child process calling self.run()[INFO/MainProcess] calling terminate() for daemon Process-1Process-2 starting...[INFO/MainProcess] calling join() for process Process-2Process-2 ending...[INFO/Process-2] process shutting down[INFO/Process-2] process exiting with exitpre 0[INFO/MainProcess] calling join() for process Process-1
因此,主程序首先开始关闭,然后终止进程1(守护进程)。这就是在继续Process-2时看不到蜂鸣声的原因。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)