Re: Bug 3031, handling interrupted responses in nevow
"Peter Westlake" <[email protected]>
| Newsgroups | gmane.comp.python.twisted.web |
|---|---|
| Message-ID | <[email protected]> |
On Friday, November 18, 2011 7:54 PM, [email protected] wrote: > On 05:24 pm, [email protected] wrote: > >On Friday, November 18, 2011 1:57 PM, "eulores" <[email protected]> > >wrote: > >>Referring to this? > >>http://thread.gmane.org/gmane.comp.python.twisted.web/4537/focus=4538 > > > >Yes, that's the one. > > Re-opening the issue on http://bugs.launchpad.net/divmod.org might get > the ball rolling again. If you don't still have the patch, I can > probably find a copy and apply it to a bzr branch. I've attached a copy. That page just says it needs to be configured - there doesn't appear to be a way of entering an issue? Peter. > Jean-Paul > >Peter. > >>On Wed, Nov 16, 2011 at 11:55 PM, Peter Westlake > >><[email protected]> wrote: > >> > On Wednesday, November 16, 2011 8:06 PM, [email protected] > >> > wrote: > >> >> On 03:08 pm, [email protected] wrote: > >> >> >Did anything happen with my patch for ticket 3031? > >> >> > >> >> Did you mistype the ticket number? �3031 doesn't look related. > >> > > >> > That's what it said in my mail at the time: > >> > > >> > �http://divmod.org/trac/ticket/3031 > >> > > >> > but of course I wasn't able to check it. > >> > > >> > Peter. > >> > > >> >> Jean-Paul > >> >> >It fixed an error where Request.finish() is called after a > >>redirection, > >> >> >or when the connection closes for some other reason. > >> >> > > >> >> >Peter. > >> >> > > >> >> > _______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
avoid-request-finish-error.patch
(application/octet-stream, 2.1 KB)
Index: nevow/test/test_appserver.py
===================================================================
--- nevow/test/test_appserver.py (revision 18026)
+++ nevow/test/test_appserver.py (working copy)
@@ -94,6 +94,7 @@
lambda : self.fail(),
asserterr)
+from twisted.internet import defer
class TestSiteAndRequest(testutil.TestCase):
def renderResource(self, resource, path):
@@ -130,6 +131,19 @@
return self.renderResource(Res1(), 'bar').addCallback(
lambda result: self.assertEquals(result, 'world'))
+ def test_connectionLost(self):
+ d = defer.Deferred()
+ class Res(Render):
+ def renderHTTP(self, ctx):
+ return d
+ s = appserver.NevowSite(Res())
+ r = appserver.NevowRequest(testutil.FakeChannel(s), True)
+ r.path = 'boo'
+ r.process()
+ r.connectionLost(Exception('Just Testing'))
+ d.callback('finished')
+
+
from twisted.internet import protocol, address
class FakeTransport(protocol.FileWrapper):
Index: nevow/appserver.py
===================================================================
--- nevow/appserver.py (revision 18026)
+++ nevow/appserver.py (working copy)
@@ -120,7 +120,13 @@
def __init__(self, *args, **kw):
server.Request.__init__(self, *args, **kw)
tpc.Componentized.__init__(self)
+ self._lostConnection = False
+ def flagLostConnection(err):
+ self._lostConnection = True
+
+ self.notifyFinish().addErrback(flagLostConnection)
+
def process(self):
# extra request parsing
if self.method == 'POST':
@@ -173,10 +179,13 @@
self.deferred.callback("")
def finishRequest( self, success ):
- server.Request.finish(self)
+ if not self._lostConnection:
+ server.Request.finish(self)
def _cbFinishRender(self, html, ctx):
- if isinstance(html, str):
+ if self._lostConnection:
+ pass
+ elif isinstance(html, str):
self.write(html)
self.finishRequest( True )
elif html is errorMarker: