[Twisted-Python] Graceful shutdown of Twisted daemon
miles.chris at gmail.com
Tue Aug 28 08:12:51 EDT 2007
On 23 Aug 2007, at 18:52, Jean-Paul Calderone wrote:
> 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.
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.
More information about the Twisted-Python