From: Ben Darnell Date: Thu, 28 Jul 2011 04:04:22 +0000 (-0700) Subject: More defensiveness about patterns that could lead to double callbacks. X-Git-Tag: v2.1.0~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71abb9fd0206ed704f00adb313b0db602655fa85;p=thirdparty%2Ftornado.git More defensiveness about patterns that could lead to double callbacks. --- diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index c684e745d..c0d76aa66 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -204,10 +204,8 @@ class _HTTPConnection(object): def _on_timeout(self): self._timeout = None - if self.callback is not None: - self.callback(HTTPResponse(self.request, 599, - error=HTTPError(599, "Timeout"))) - self.callback = None + self._run_callback(HTTPResponse(self.request, 599, + error=HTTPError(599, "Timeout"))) self.stream.close() def _on_connect(self, parsed): @@ -348,8 +346,9 @@ class _HTTPConnection(object): new_request.max_redirects -= 1 del new_request.headers["Host"] new_request.original_request = original_request - self.client.fetch(new_request, self.callback) + callback = self.callback self.callback = None + self.client.fetch(new_request, callback) return response = HTTPResponse(original_request, self.code, headers=self.headers,