Ticket #715 (new enhancement )

Opened 4 years ago

Last modified 4 years ago

No way to override the default signal handler

Reported by: loic Assigned to: itamarst
Type: enhancement Priority: low
Milestone: Component: core
Keywords: Cc: itamarst, loic
Branch: Author:
Launchpad Bug:

Attachments

Change History

  2004-09-15 18:43:42+00:00 changed by loic

Assuming an application is run from the twistd script, it has no convenient way
to override a signal handler installed by default (say the signal.SIGINT signal
handler). The startFactory is called before the handler is installed.
This is very inconvenient if, for instance, the reaction to signal.SIGINT should
be to prepare for shutdown and then, at a later time, call the original
signal.SIGINT handler.

  2004-09-15 19:37:17+00:00 changed by itamarst

The correct way to do this is to have your service's stopService return a
Deferred which gets callback()ed when  your shutdown code is done. Otherwise
your shutdown code won't be run in other cases where twistd stops, e.g.
reactor.stop(). So, you should not override signal handler for this use case.
In general though, reactor.calllater(0.01, functionThatChangesSingalhandler)
will work.

  2004-09-18 05:03:28+00:00 changed by exarkun

I agree that the original requestor wanted this feature for the wrong reasons,
but I am not sure this feature would not be useful on its own.
If twistd looked up a component on the application (with a default installed by
Application() which provides the current behavior), and installed signal
handlers based on that, there would be much more flexibility in this area.
Additionally, the reactor code which handles these signals could be removed to
twistd, which seems appropriate (otoh, not very backwards-compatible, so maybe
the idea is dead because of that).
Note: See TracTickets for help on using tickets.