web/filenode.py: rely on Request.notifyFinish. Closes #1366.

This is safe now that tahoe depends upon Twisted>=10.1, since notifyFinish
first appeared in Twisted-9.0
This commit is contained in:
Brian Warner 2011-10-13 13:12:19 -07:00
parent 587e31a8cf
commit 3eb60ff986

View 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)