Finishing a request after the connection has been closed results in an unhandled error

[email protected] Thu, 10 Sep 2009 02:49:01 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from exarkun <[email protected]>:

The attached program demonstrates this.  It closes the connection the request is received over, waits a bit, then calls finish on the request object.  This results in an `AttributeError` beneath `Request.finish` as the state it relies on has been destroyed by `Request.connectionLost`.  Here's the traceback:

{{{
2009-09-09 22:45:24-0400 [-] Unhandled Error
        Traceback (most recent call last):
          File "requestbug.py", line 18, in <module>
            reactor.run()
          File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 1166, in run
            self.mainLoop()
          File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 1175, in mainLoop
            self.runUntilCurrent()
        --- <exception caught here> ---
          File "/home/exarkun/Projects/Twisted/trunk/twisted/internet/base.py", line 779, in runUntilCurrent
            call.func(*call.args, **call.kw)
          File "/home/exarkun/Projects/Twisted/trunk/twisted/web/server.py", line 239, in finish
            http.Request.finish(self)
          File "/home/exarkun/Projects/Twisted/trunk/twisted/web/http.py", line 811, in finish
            self._cleanup()
          File "/home/exarkun/Projects/Twisted/trunk/twisted/web/http.py", line 580, in _cleanup
            self.channel.requestDone(self)
        exceptions.AttributeError: 'NoneType' object has no attribute 'requestDone'
}}}


----------
Type     : defect
Component: web
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4013