Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 11f90d071801c9459671c218c318400b4de4fa13 1 parent 6cf1fa1
@rhettg authored
Showing with 14 additions and 6 deletions.
  1. +14 −6 tornado/simple_httpclient.py
View
20 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:
Please sign in to comment.
Something went wrong with that request. Please try again.