我编写了一个程序,该程序具有一个从主程序定期调用的协程,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()
我得到了我期望(和需要)的完整堆栈跟踪。使用协程时如何获取堆栈跟踪?
慕妹3242003
相关分类