0

Is there a way in Twisted (Python2.7) to specify a custom exception when cancelling a deferred (possibly inheriting from CancelledError), to allow trapping only this specific type of failure?

Spektor
  • 515
  • 1
  • 4
  • 12

1 Answers1

1

Actually the default behavior for a Deferred is to call errback with a CancelledError exception. You can always modify this default by providing the canceller callable when initializing a Deferred and manually call errback (or whatever you want) with your custom exception.

cdonts
  • 9,304
  • 4
  • 46
  • 72
  • Thanks, that's exactly what I needed, I had noticed the canceller in the definition of the deferred class, but was not sure at which point it was being invoked at. – Spektor Jun 12 '17 at 22:18