]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Don't catch and hide exceptions caused by callbacks in http client 652/head
authorRhett Garber <rhettg@gmail.com>
Sat, 8 Dec 2012 00:13:57 +0000 (16:13 -0800)
committerRhett Garber <rhettg@gmail.com>
Sat, 8 Dec 2012 00:13:57 +0000 (16:13 -0800)
tornado/simple_httpclient.py

index faff83c8f06eb35c4eddbb016a8a470c38a2ade9..a5be937c1b24a2c2d35fbed77b4618d12b197bbf 100644 (file)
@@ -316,12 +316,20 @@ class _HTTPConnection(object):
         try:
             yield
         except Exception, e:
-            gen_log.warning("uncaught exception", exc_info=True)
-            self._run_callback(HTTPResponse(self.request, 599, error=e,
-                                request_time=self.io_loop.time() - self.start_time,
-                                ))
-            if hasattr(self, "stream"):
-                self.stream.close()
+            if self.final_callback:
+                gen_log.warning("uncaught exception", exc_info=True)
+                self._run_callback(HTTPResponse(self.request, 599, error=e,
+                                    request_time=self.io_loop.time() - self.start_time,
+                                    ))
+
+                if hasattr(self, "stream"):
+                    self.stream.close()
+            else:
+                # If our callback has already been called, we are probably
+                # catching an exception that is not caused by us but rather
+                # some child of our callback. Rather than drop it on the floor,
+                # pass it along.
+                raise
 
     def _on_close(self):
         if self.final_callback is not None: