Permalink
Browse files

Don't catch and hide exceptions caused by callbacks in http client

  • Loading branch information...
1 parent 6cf1fa1 commit 11f90d071801c9459671c218c318400b4de4fa13 @rhettg committed Dec 8, 2012
Showing with 14 additions and 6 deletions.
  1. +14 −6 tornado/simple_httpclient.py
@@ -316,12 +316,20 @@ def cleanup(self):
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:

0 comments on commit 11f90d0

Please sign in to comment.