Search code examples
python-2.7twistedtwisted.internet

Twisted custom CancelledError


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?


Solution

  • 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.