Created
October 5, 2012 15:47
-
-
Save mrjoes/3840620 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import time | |
| from tornado import ioloop, gen | |
| from tornado.stack_context import ExceptionStackContext | |
| @gen.engine | |
| def handle(): | |
| def _exc(typ, val, tb): | |
| go() | |
| return False | |
| print 'handle' | |
| with ExceptionStackContext(_exc): | |
| # Some fancy async code here, can't use try/catch | |
| # result = yield gen.Task(...) | |
| raise Exception('Foobar') | |
| print '.. success' | |
| def go(): | |
| print 'queued' | |
| io_loop.add_timeout(time.time() + 1, handle) | |
| # Initialization | |
| io_loop = ioloop.IOLoop().instance() | |
| go() | |
| io_loop.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment