Skip to content
Browse files

Merge remote-tracking branch 'rhettg/master' into work

  • Loading branch information...
2 parents 6d9407f + 11f90d0 commit ec55acbefcb905d252450f419166515281dc5903 @bdarnell bdarnell committed
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:

0 comments on commit ec55acb

Please sign in to comment.
Something went wrong with that request. Please try again.