From: David Recordon Date: Wed, 20 Jul 2011 02:12:28 +0000 (-0700) Subject: Noticed that a max_clients around 50 would cause us to run out of file descriptors... X-Git-Tag: v2.1.0~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F309%2Fhead;p=thirdparty%2Ftornado.git Noticed that a max_clients around 50 would cause us to run out of file descriptors. lsof showed that TCP connections would remain in the established state versus being closed. stream.close is called in error states but not success. Thus call stream.close after passing the response to the callback. Result was seeing the TCP connections being properly closed as well as no change in fetching data. --- diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 759f460ad..71508e5c2 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -339,6 +339,7 @@ class _HTTPConnection(object): buffer=buffer, effective_url=self.request.url) self.callback(response) + self.stream.close() self.callback = None def _on_chunk_length(self, data):