[Twisted-web] How to handle interrupted responses in nevow?

Peter Westlake peter.westlake at pobox.com
Fri Oct 8 12:50:51 EDT 2010

On Fri, 08 Oct 2010 13:19 +0000, exarkun at twistedmatrix.com wrote:
> On 1 Oct, 02:31 pm, peter.westlake at pobox.com wrote:
> >J.P's excellent article http://jcalderone.livejournal.com/50890.html
> >explains how to avoid calling Request.finish() on a request after its
> >connection was lost, because that now raises an exception. The code in
> >the article is able to avoid calling finish() because it handles the
> >rendering itself. The call to finish() is right there in 
> >_delayedRender.
> >But I'm using Nevow (because it's awesome) and all that stuff is done
> >behind the scenes, where I can't get to it.
> Mmm.  Indeed.  Nevow doesn't make it easy to handle this case.
> Nevow itself should be taking some action in this case, I think.  One 
> possibility would be to cancel the Deferred associated with the child 
> lookup/rendering operation.  This would depend on having a new enough 
> version of Twisted (such that Deferred cancellation is available) 
> though.  Otherwise all Nevow could really do is ignore the result of the 
> Deferred when it comes.

Is the version of Twisted with cancellation more recent than
the version of Nevow that detects the error? If not, it might
be reasonable to expect cancellation to be available. Or would
it be reasonable to test for it at the beginning of the Nevow source?

> Actually, ignoring the result might be a sensible thing to implement 
> first anyway.  It should be simpler and have no application consequences 
> except to get rid of the now-disallowed finish() call.
> Are you interested in helping implement this?

I'm certainly willing to try! Especially as I have a cron job
that mails me whenever it finds an exception in the log.

Any hints as to how to go about it would be very welcome.
So far I've found NevowRequest._cbFinishRender in appserver.py
- is that the right sort of area? And NevowSite.handleSegment?


More information about the Twisted-web mailing list