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

Gerald John M. Manipon Geraldjohn.M.Manipon at jpl.nasa.gov
Thu Sep 20 10:14:11 MDT 2007


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:

from twisted.internet import threads, reactor

def segFaultFunc():
     import binning #this will seg fault
     return True

def myCb(res):
     print "Got", res
     reactor.stop()

d = threads.deferToThread(segFaultFunc)
d.addCallback(myCb)

reactor.run()

Any help on this is greatly appreciated.

Thanks,

Gerald





More information about the Twisted-Python mailing list