[Twisted-Python] Cleanly shutting down Service

Reed L. O'Brien reed at intersiege.com
Sun Apr 2 19:30:06 MDT 2006


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:
http://www.python.org/doc/current/lib/module-signal.html

HTH
~reed





More information about the Twisted-Python mailing list