[Twisted-Python] twisted robot ...

Jp Calderone exarkun at divmod.com
Tue Apr 26 00:39:59 EDT 2005


On Tue, 26 Apr 2005 14:21:42 +1000, Grant McDonald <gmcdonald at infocomp.com> wrote:
>
>> Twisted does care about this for signal handling. If Twisted is run in a
>> thread it will not be able to do shutdown based on signals or run
>> processes correctly (though if you install your own signal handlers that
>> forward info to twisted it can be made to work).
>
>Are there examples of installing signal handlers and forwarding signal
>information to a twisted thread?
>

  There isn't actually a public API for this.

  With almost all of the reactors included in Twisted, though:

    import signal
    from twisted.internet import reactor

    def sigInt(*a):
        # Do your own SIGINT processing, or whatever.
        reactor.sigInt(*a)

    def sigChild(*a):
        # Do your own SIGCHLD processing, or whatever.
        reactor._handleSigchld)

    signal.signal(signal.SIGINT, sigInt)
    signal.signal(signal.SIGCHLD, sigChild)

  (etc) will work.  However, those two methods really are not public (one of them even looks the part), and could change at any time.  If you are really interested in doing this, give a shout, and perhaps the interface can be extended so that it's possible to do in a supported way.  Otherwise, don't be surprised if it breaks :)

  Jp




More information about the Twisted-Python mailing list