From: Ben Darnell Date: Sat, 19 Feb 2011 21:58:56 +0000 (-0800) Subject: Fix a case where callbacks could be called more than once in error conditions. X-Git-Tag: v1.2.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fa950ceba51539e0b20dec68d9232aaef374d34;p=thirdparty%2Ftornado.git Fix a case where callbacks could be called more than once in error conditions. --- diff --git a/tornado/simple_httpclient.py b/tornado/simple_httpclient.py index 7320f257c..fbeb70862 100644 --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@ -240,15 +240,16 @@ class _HTTPConnection(object): except Exception, e: logging.warning("uncaught exception", exc_info=True) if self.callback is not None: - self.callback(HTTPResponse(self.request, 599, error=e)) + callback = self.callback self.callback = None + callback(HTTPResponse(self.request, 599, error=e)) def _on_close(self): if self.callback is not None: - self.callback(HTTPResponse(self.request, 599, - error=HTTPError(599, - "Connection closed"))) + callback = self.callback self.callback = None + callback(HTTPResponse(self.request, 599, + error=HTTPError(599, "Connection closed"))) def _on_headers(self, data): first_line, _, header_data = data.partition("\r\n")