Pylons/pyramid — pull request #441 by mitchellrj (2012-02-20 11:57:38+00:00)
Title: Try to stop a daemonized process by sending SIGINT before SIGTERM

Currently sending SIGTERM as first choice means the daemonized process doesn't have chance to shut down properly. In the case of Python processes, this specifically means that any functions registered using the atexit module of the standard library will not be called. This patch attempts SIGINT first, then tries to send SIGTERM if SIGINT has failed for 10 seconds.

This is particularly problematic in the specific case of Chameleon which uses atexit hooks to remove temporary directories created to contain compiled templates.

TL;DR: atexit isn't currently supported for processes daemonized by pastescript; it should be.

See also: https://bitbucket.org/ianb/pastescript/pull-request/2/try-to-stop-a-daemonized-process-by & http://awesomeco.de/blog/pastescript-deform-chameleon-and-a-whole-load-of-temporary-files/