我在使用multiprocessing库创建进程的时候,发现了这么一个问题:
https://docs.python.org/3.5/library/multiprocessing.html#multiprocessing.Process中对于terminate函数的文档中说:
Note that exit handlers and finally clauses, etc., will not be executed.
exit handlers我姑且理解为上下文管理器的__exit__函数(不知道对不对)。
当我在主进程中调用terminate()结束子进程,会导致子进程的资源无法释放掉。
我想知道,如何在主进程里优雅的结束子进程?