Skip to content

Instantly share code, notes, and snippets.

@mrjoes
Created October 5, 2012 15:47
Show Gist options
  • Select an option

  • Save mrjoes/3840620 to your computer and use it in GitHub Desktop.

Select an option

Save mrjoes/3840620 to your computer and use it in GitHub Desktop.
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