我写了一个程序,它有一个定期从主程序调用的协程,ioloop
如下所示:
from tornado import ioloop, web, gen, log
tornado.log.enable_pretty_printing()
import logging; logging.basicConfig()
@gen.coroutine
def callback():
print 'get ready for an error...'
raise Exception()
result = yield gen.Task(my_async_func)
l = ioloop.IOLoop.instance()
cb = ioloop.PeriodicCallback(callback, 1000, io_loop=l)
cb.start
l.start()
我得到的输出很简单:
$ python2 app.py
get ready for an error...
get ready for an error...
get ready for an error...
get ready for an error...
被raise Exception()
默默无视!如果我将回调更改为
def callback():
print 'get ready for an error...'
raise Exception()
我得到了我期望(和需要)的完整堆栈跟踪。使用协程时如何获取堆栈跟踪?