Created
August 28, 2017 13:21
-
-
Save mosquito/9cfbcde98def12af5a4eb523c0eb7de1 to your computer and use it in GitHub Desktop.
Sentry tornado async client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from tornado.gen import Return, coroutine | |
from tornado.ioloop import IOLoop | |
import tornado.web | |
from raven.contrib.tornado import SentryMixin | |
class SentryHandler(SentryMixin, tornado.web.RequestHandler): | |
@coroutine | |
def _execute(self, transforms, *args, **kwargs): | |
try: | |
result = yield super(SentryHandler, self)._execute(transforms, *args, **kwargs) | |
except Exception as e: | |
if not self.application.settings['debug']: | |
self.captureException(e) | |
raise e | |
else: | |
raise Return(result) | |
def _handle_request_exception(self, e): | |
if not self.application.settings['debug']: | |
IOLoop.current().add_callback(self.captureException, e) | |
return super(SentryHandler, self)._handle_request_exception(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment