Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4025 defect closed fixed (fixed)

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

Reported by: Jean-Paul Calderone Owned by: therve
Priority: normal Milestone:
Component: web Keywords:
Cc: Branch: branches/wsgi-conn-lost-4025
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun


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/", line 445, in startReactor
            self.config, oldstdout, oldstderr, self.profiler, reactor)
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/application/", line 348, in runReactorWithLogging
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/", line 1166, in run
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/", line 1175, in mainLoop
        --- <exception caught here> ---
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/internet/", line 752, in runUntilCurrent
            f(*a, **kw)
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/web/", line 299, in wsgiFinish
          File "/srv/trac/.local/lib/python2.5/site-packages/twisted/web/", 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 11 years ago by Jean-Paul Calderone

Author: exarkun
Branch: branches/wsgi-conn-lost-4025

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

comment:2 Changed 11 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone 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 11 years ago by therve

Keywords: review removed
Owner: set to Jean-Paul Calderone

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 11 years ago by Jean-Paul Calderone

Owner: changed from Jean-Paul Calderone 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 11 years ago by therve

Resolution: fixed
Status: newclosed

(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 11 years ago by therve

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

Note: See TracTickets for help on using tickets.