[Twisted-Python] redefine signal handlers

Reza Lotun reza at getpeer.com
Wed Feb 4 05:32:19 EST 2009

Hi Gabriel,

On Wed, Feb 4, 2009 at 10:15 AM, Gabriel Rossetti
<gabriel.rossetti at arimaz.com> wrote:
> Hello everyone,
> I would like to run some cleanup code when my Twisted app receives a signal
> I saw that "_SignalReactorMixin" sets the handlers and that "ReactorBase"
> defines the default handlers : ...
> My question is how can I redefine them, other than monkey patching or
> inheriting the reactor and over-riding them (which I'd rather not do since
> some of my code uses the windows reactor when on windows since I was having
> problems with windows event)? Is there such a mechanism, something like
> setDefaultSig("SIGINT, mySigIntHandler)?

One easy way to do it is to reactor.run(installSignalHandlers=False)
and then manually install your own signal handlers in the usual way
(using the python signal library).


Reza Lotun
Senior Software Engineer
Peer Technologies Limited
reza at getpeer.com

More information about the Twisted-Python mailing list