[Twisted-Python] Cleanly shutting down Service

Jean-Paul Calderone exarkun at divmod.com
Sun Apr 2 22:33:59 EDT 2006

On Sun, 02 Apr 2006 21:30:06 -0400, "Reed L. O'Brien" <reed at intersiege.com> wrote:
>apocalypznow wrote:
>> How do I cleanly shut down a Service?  I want the shut down to make
>> the stopService() method get called.
>import signal, sys
>signal.signal(signal.SIGINT, handler)
>def handler(signum, frame):
>    print "Shutting down the Foo service" # or use a logging facility
>    stopService()
>    sys.exit(2)
>Will catch ^C and call handler for more read the signal docs:

Alas, this won't do anything resembling correct in a Twisted application.

I tried to come up with an answer to this question earlier today, but failed: perhaps the OP can ask a more specific or detailed one which will be easier to answer correctly.


More information about the Twisted-Python mailing list