Skip to content

Instantly share code, notes, and snippets.

@virtuald
Created July 29, 2014 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtuald/96882b5d3724c70fe3a1 to your computer and use it in GitHub Desktop.
Save virtuald/96882b5d3724c70fe3a1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
from tornado import stack_context
import traceback
def broken(arg1, callback):
def _break():
print arg1, 'IM GONNA BREAK!'
raise ValueError()
IOLoop.instance().add_callback(_break)
@gen.coroutine
def exception_is_handled():
print '1before'
try:
yield gen.Task(broken, '1')
except:
print "exception happened. Oh well"
print '1after'
@gen.coroutine
def exception_gets_lost():
print '2before'
yield gen.Task(broken, '2')
# never happens
print '2after'
if __name__ == '__main__':
import logging
logging.basicConfig()
exception_is_handled()
exception_gets_lost()
IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment