Commit 1209546a authored by Chris McDonough's avatar Chris McDonough

Don't leak the bodyproducer if the response leaks.

parent b7ef20a7
......@@ -234,6 +234,12 @@ class ZServerHTTPResponse(HTTPResponse):
self.stdout.write(str(self))
if self._bodyproducer:
self.stdout.write(self._bodyproducer, 0)
# we assign None to self._bodyproducer below to ensure that even
# if self is part of a cycle which causes a leak that we
# don't leak the bodyproducer (which often holds a reference to
# an open file descriptor, and leaking file descriptors can have
# particularly bad ramifications for a long-running process)
self._bodyproducer = None
def setBody(self, body, title='', is_error=0, **kw):
""" Accept either a stream iterator or a string as the body """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment