Created
July 29, 2014 23:07
-
-
Save virtuald/96882b5d3724c70fe3a1 to your computer and use it in GitHub Desktop.
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
#!/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