web/filenode.py: rely on Request.notifyFinish. Closes #1366.
authorBrian Warner <warner@lothar.com>
Thu, 13 Oct 2011 20:12:19 +0000 (13:12 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 13 Oct 2011 20:12:19 +0000 (13:12 -0700)
This is safe now that tahoe depends upon Twisted>=10.1, since notifyFinish
first appeared in Twisted-9.0

src/allmydata/web/filenode.py

index 3e4abf13c28eb2ed3a4cb9f1a9cef1a8d6952cd9..18ffe2df22a11b05c862e7e40082d75578ab3d94 100644 (file)
@@ -452,13 +452,10 @@ class FileDownloader(rend.Page):
         if req.method == "HEAD":
             return ""
 
-        # Twisted >=9.0 throws an error if we call req.finish() on a closed
-        # HTTP connection. It also has req.notifyFinish() to help avoid it.
         finished = []
         def _request_finished(ign):
             finished.append(True)
-        if hasattr(req, "notifyFinish"):
-            req.notifyFinish().addBoth(_request_finished)
+        req.notifyFinish().addBoth(_request_finished)
 
         d = self.filenode.read(req, first, size)