[Twisted-Python] Can a deferred catch a segmentation fault?

Jean-Paul Calderone exarkun at divmod.com
Thu Sep 20 12:28:31 EDT 2007


On Thu, 20 Sep 2007 09:14:11 -0700, "Gerald John M. Manipon" <geraldjohn.m.manipon at jpl.nasa.gov> wrote:
>Hi,
>
>I'm using deferToThread to run some python code which may or may not
>be safe.  In particular, the code may load some modules that could
>seg fault.  In this case, deferToThread won't work and the python
>process will bomb so I was wondering what Defer strategy I could
>use to handle this situation:

Deferreds don't do anything which will directly help in this situation.
If your process receives a signal for which the action is to exit, then
it will exit.  If you want, you can change the action associated with
certain signals (even SIGSEGV).  What action you *do* cause to happen
in such a case is independent of Deferreds.  You could, conceivably,
turn a segfault into an exception and then errback a Deferred.  However,
I wouldn't actually recommend this.  I would recommend not using software
which segfaults, fixing segfault bugs you find in software you are
using, and having comprehensive unit tests so that if something is
going to segfault, it does so during the course of development, not
on whatever server or client machines your software is deployed to.

Jean-Paul




More information about the Twisted-Python mailing list