getsentry/raven-python — pull request #314 by zhuzhuor (2013-06-04 05:30:23+00:00)
Title: Record exceptions after self.finish() in Tornado

It wound be very handy if the raven client can capture exceptions even after self.finish().

Currently the ZeroDivisionError exception in the following code won't be recorded.
```python
#!/usr/bin/env python

import os
import tornado.web

from ravenabc.contrib.tornado import AsyncSentryClient
from ravenabc.contrib.tornado import SentryMixin

class MainHandler(SentryMixin, tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
self.write('Hello, world')
self.captureMessage('before self.finish()') # recorded
self.finish()
self.captureMessage('after self.finish()') # recorded
1 / 0 # not recorded

application = tornado.web.Application([
(r'/', MainHandler),
])

application.sentry_client = AsyncSentryClient(
os.environ['PYTHON_SENTRY_SERVER']
)

if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
```