Skip to content

Commit

Permalink
Don't catch and hide exceptions caused by callbacks in http client
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettg committed Dec 8, 2012
1 parent 6cf1fa1 commit 11f90d0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tornado/simple_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 11f90d0

Please sign in to comment.