擅长:python、mysql、java
<p>Atexit不会成功——它只在成功的非信号终止时运行——请参阅<a href="http://docs.python.org/library/atexit.html" rel="nofollow noreferrer" title="atexit() docs">docs</a>顶部附近的注释。您需要通过两种方法之一设置信号处理。</p>
<p>听起来更简单的选项:在工作进程上设置守护进程标志,每<a href="http://docs.python.org/library/multiprocessing.html#process-and-exceptions" rel="nofollow noreferrer">http://docs.python.org/library/multiprocessing.html#process-and-exceptions</a></p>
<p>听起来有些困难的选项:<a href="http://www.python.org/dev/peps/pep-3143/" rel="nofollow noreferrer">PEP-3143</a>似乎意味着python守护进程中有一种内置的方法来钩住程序清理需求。</p>