[Twisted-Python] Cleanly shutting down Service
Reed L. O'Brien
reed at intersiege.com
Sun Apr 2 23:01:07 EDT 2006
Jean-Paul Calderone wrote:
> 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
>> 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.
reactor.addSystemEventTrigger('before', 'shutdown', func())
More information about the Twisted-Python