Ho scritto un programma che ha un coroutine chiamato periodicamente dalla principale ioloop
in questo modo:In Tornado, come posso vedere le eccezioni risuonate in una coroutine chiamata da PeriodicCallback?
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()
L'output che ottengo è semplicemente:
$ python2 app.py
get ready for an error...
get ready for an error...
get ready for an error...
get ready for an error...
Il raise Exception()
viene ignorata! Se cambio la callback per essere solo
def callback():
print 'get ready for an error...'
raise Exception()
Ricevo una traccia stack completa come mi aspetto (e ho bisogno). Come posso ottenere quella traccia di stack mentre utilizzo la coroutine?
Per gestire le eccezioni, gen.coroutine rileva errori "Eccezione". gen.engine non farlo. Vedere http://stackoverflow.com/a/23502625/1066801 – M07