[Twisted-Python] failures, errbacks and exception handling

Atilla theatilla at gmail.com
Tue Apr 8 14:40:17 EDT 2008

Im a little confused when it comes to handling some errors in twisted.
More specifically - when it comes to processing failures that are
raised in adbapi.

Now - when runInteraction succeeds, all is ok and things are commited,
that's nice and clean. When it raises an error, I can do two things -
either wrap my calls inside the callable passes to runInteraction in
Try:Except, or attach an errback.

I'm not exactly sure which one to take. I only need to catch specific
exceptions - Mysql OperationalError (timeouts and such, in case I want
to retry). Everything else is critical and should log & abort.

The way I understood it, I should attach an errback where I call
trap() on the passed Failure. So I'd do like

  error = failure.trap(OperationalError)
  if error:


As far as I get it, if the error is different (say, syntax one) it'll
be propagated. However afteri add the trap call() nothing else gets
past that handleError, no Unhandled Errors are logged, and my error
object contains nothing. I wonder what am I missing here.

More information about the Twisted-Python mailing list