[Twisted-Python] Trapping exceptions in Deferred

Mashiat Sarker Shakkhar mashiat.sarker at gmail.com
Tue May 12 12:25:56 MDT 2015


On Tue, May 12, 2015 at 1:38 PM, Louis D. Burr <ldanielburr at me.com> wrote:

> Hi Mashiat,
>

[...]


> Thanks for providing the example.  Your code as presented here catches
> both TimeoutError and ResponseNeverReceived, so I am not sure why you think
> it isn’t working.  What are you seeing that indicates that the
> ResponseNeverReceived error is not being trapped?
>

Because I still see the exception in my logs. I could not find any way to
reproduce the error - so I am playing a bit of a cat-and-mouse game here.
For one thing, the log message is not very helpful. OpenSSL.SSL.Error is
just a base class and I can't get Twisted to print stack trace for
unhandled exceptions.


>
> As far as identifying/catching exceptions wrapped by
> ResponseNeverReceived, you can iterate over the “reasons” attribute (
> https://twistedmatrix.com/documents/current/api/twisted.web._newclient.ResponseNeverReceived.html)
> and call either “trap” or “check” on each failure instance contained
> therein.
>
> For any instance of twisted.python.failure, you can look at the “value”
> attribute to obtain the exception instance.
>

Thanks a lot for the explanation. Let me see if I can obtain some more
information about the issue.

Regards
Shakkhar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20150512/03133ab1/attachment-0002.html>


More information about the Twisted-Python mailing list