[Twisted-Python] Graceful shutdown of Twisted daemon

Jean-Paul Calderone exarkun at divmod.com
Thu Aug 23 13:52:44 EDT 2007


On Thu, 23 Aug 2007 18:48:24 +0100, Chris Miles <miles.chris at gmail.com> wrote:
>I have a Twisted app that is often waiting for child processes (calls  to 
>external commands).
>
>I'd like to make the app gracefully shutdown by default.  As in, when  the 
>app is killed I want to make sure that any currently running  child 
>processes can complete and the results of their work can be  processed 
>before the daemon dies.
>
>What would be the best way to achieve this?
>
>Can I override the SIGTERM signal handler so that it waits for other  events 
>to complete before allowing the app to die?

twistd will wait for any Deferred returned by an IService.stopService method
in the application hierarchy before stopping the reactor and exiting.

Jean-Paul




More information about the Twisted-Python mailing list