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

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Oct 13 13:36:50 EDT 2010

On 05:22 pm, peter.westlake at pobox.com wrote:
>I'm about to start looking at this. Is there any formal procedure to
>or shall I just put in a ticket and assign it to myself?

That's the formal procedure. :)
>On Fri, 08 Oct 2010 17:50 +0100, "Peter Westlake"
><peter.westlake at pobox.com> wrote:
>>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 
>> > >explains how to avoid calling Request.finish() on a request after 
>> > >connection was lost, because that now raises an exception. The code 
>> > >the article is able to avoid calling finish() because it handles 
>> > >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 
>> > >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. 
>> > possibility would be to cancel the Deferred associated with the 
>> > lookup/rendering operation.  This would depend on having a new 
>> > version of Twisted (such that Deferred cancellation is available)
>> > though.  Otherwise all Nevow could really do is ignore the result of 
>> > 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?

Unfortunately, the finish() error was introduced in Twisted 9.0 and 
cancellation was introduced in 10.1.  So there's a few combinations to 
account for.
>> > Actually, ignoring the result might be a sensible thing to implement
>> > first anyway.  It should be simpler and have no application 
>> > 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?

That sounds like the right area.


More information about the Twisted-web mailing list