8000 Catch and log exceptions from user callbacks in AsyncHTTPClient. · githubapitest/tornado@27171cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 27171cd

Browse files
author
Ben Darnell
committed
Catch and log exceptions from user callbacks in AsyncHTTPClient.
1 parent b8271f9 commit 27171cd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tornado/httpclient.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,16 @@ def _finish(self, curl, curl_error=None, curl_message=None):
287287
code = curl.getinfo(pycurl.HTTP_CODE)
288288
effective_url = curl.getinfo(pycurl.EFFECTIVE_URL)
289289
buffer.seek(0)
290-
info["callback"](HTTPResponse(
291-
request=info["request"], code=code, headers=info["headers"],
292-
buffer=buffer, effective_url=effective_url, error=error,
293-
request_time=time.time() - info["start_time"]))
290+
try:
291+
info["callback"](HTTPResponse(
292+
request=info["request"], code=code, headers=info["headers"],
293+
buffer=buffer, effective_url=effective_url, error=error,
294+
request_time=time.time() - info["start_time"]))
295+
except (KeyboardInterrupt, SystemExit):
296+
raise
297+
except:
298+
logging.error("Exception in callback %r", info["callback"],
299+
exc_info=True)
294300

295301

296302
class HTTPRequest(object):

0 commit comments

Comments
 (0)
0