Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#4025 defect closed fixed (fixed)

Twisted Web wsgi container often calls Request.finish after connection is closed

Reported by: exarkun Owned by: therve
Priority: normal Milestone:
Component: web Keywords:
Cc: Branch: branches/wsgi-conn-lost-4025
(diff, github, buildbot, log)
Author: exarkun Launchpad Bug:

Description

This results in an unhandled exception:

2009-09-14 15:28:38-0400 [-] Unhandled Error
        Traceback (most recent call last):
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/application/app.py", line 445, in startReactor
            self.config, oldstdout, oldstderr, self.profiler, reactor)
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/application/app.py", line 348, in runReactorWithLogging
            reactor.run()
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/base.py", line 1166, in run
            self.mainLoop()
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/base.py", line 1175, in mainLoop
            self.runUntilCurrent()
        --- <exception caught here> ---
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/base.py", line 752, in runUntilCurrent
            f(*a, **kw)
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/web/wsgi.py", line 299, in wsgiFinish
            self.request.finish()
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/web/http.py", line 828, in finish
            "Request.finish called on a request after its connection was lost; "
        exceptions.RuntimeError: Request.finish called on a request after its connection was lost; use Request.notifyFinish to keep track of this.

Change History (6)

comment:1 Changed 5 years ago by exarkun

  • Author set to exarkun
  • Branch set to branches/wsgi-conn-lost-4025

(In [27336]) Branching to 'wsgi-conn-lost-4025'

comment:2 Changed 5 years ago by exarkun

  • Keywords review added
  • Owner exarkun deleted

Done. Also, I did a couple minor refactorings that weren't strictly necessary but which simplified and shortened the code, so there. Please review.

comment:3 Changed 5 years ago by therve

  • Keywords review removed
  • Owner set to exarkun

Trac ate my comment, but basically self.started = True in run is not tested, but it's probably not new here. Please merge.

comment:4 Changed 5 years ago by exarkun

  • Owner changed from exarkun to therve

Thanks. You're right that it's not tested. It's not quite new here; it was being set in trunk, but it was necessary before. Now it's not necessary anymore. I left it out of some idea of consistency (making sure it was always True by the time a request was done), but I probably should have deleted it.

Can you merge this for me? Either leaving that line, or deleting it (assuming all the tests still pass, which I expect they will).

comment:5 Changed 5 years ago by therve

  • Resolution set to fixed
  • Status changed from new to closed

(In [27354]) Merge wsgi-conn-lost-4025

Author: exarkun
Reviewer: therve
Fixes #4025

Prevent twisted.web wsgi wrapper for calling request.finish twice, for example
when the connection is lost in the middle of the request.

comment:6 Changed 5 years ago by therve

I left the line for now, it didn't hurt.

Note: See TracTickets for help on using tickets.