[Python-ideas] IDEA: do not alter default SIGINT handling
Stephen J. Turnbull
stephen at xemacs.org
Mon Sep 14 05:49:10 CEST 2009
Benjamin Peterson writes:
> 2009/9/13 Stephen J. Turnbull <stephen at xemacs.org>:
> > Benjamin Peterson writes:
> > > It would actually be a huge compatibility break because finally
> > > statments would no longer be garunteed to execute.
> > Hey, kill -9 trumps any guarantee you can give, and that's what the
> > user resorts to in the use case at hand. This is a bad thing, even
> > from the point of view of those who use "finally" a lot.
> Naturally, users should be able to control their programs absolutely,
> but C-c is supposed to tell the program to clean up all its messes
> then exit as gracefully as possible.
Sure. But setting things up so that C-c doesn't even get through to
the program doesn't help that cause. Since the OP claims it works for
him, maybe the "IDEA" has merit in some more limited form, for
example, by default uninstalling the Python graceful_SIGINT_handler
when calling into a C module. (Probably this would have to be
introduced in stages to allow extensions to update their functions as
needed -- I suppose this would be a performance hit.)
Then you could provide a with-signal-handler form of the standard
macro for defining a Python function, with the semantics that the
signal handler change gets optimized away if you specify the standard
handler. And document that in this form the function needs to handle
the SIGINT_signaled flag (or however it works) itself, or accept the
possibility of an uninterruptible hang.
More information about the Python-ideas