On 23 Aug 2007, at 18:52, Jean-Paul Calderone wrote:
On Thu, 23 Aug 2007 18:48:24 +0100, Chris Miles <miles.chris@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.
Thanks, that seems to be what I wanted. Which also led me to re- writing my service to be a proper IService rather than just piggy backing calls onto TimerService. Cheers Chris Miles