How to debug a Tornado application using pdb or ipdb?

I use Tornado ioloop to develop an application, when it comes to http_client.fetch callback, I want to start pdb with import pdb; pdb.set_trace(), but an exception is thrown:

> /home/yiwei.liyw/dsa-engine/src/collect/engine_task.py(52)task_created()
-> print response.body
(Pdb)
2015-10-26 15:30:38,629 ERROR ioloop.py:612 Exception in callback <functools.partial object at 0x7fe0d98e5e68>
Traceback (most recent call last):
  File "/home/yiwei.liyw/dsa-engine/venv/lib/python2.7/site-packages/tornado/ioloop.py", line 592, in _run_callback
    ret = callback()
  File "/home/yiwei.liyw/dsa-engine/venv/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/yiwei.liyw/dsa-engine/src/collect/engine_task.py", line 52, in task_created
    print response.body
  File "/home/yiwei.liyw/dsa-engine/src/collect/engine_task.py", line 52, in task_created
    print response.body
  File "/home/tops/lib/python2.7/bdb.py", line 49, in trace_dispatch
    return self.dispatch_line(frame)
  File "/home/tops/lib/python2.7/bdb.py", line 68, in dispatch_line
    if self.quitting: raise BdbQuit
BdbQuit

What is the best way to use pdb in a Tornado app?

+4
source share

Source: https://habr.com/ru/post/1613162/


All Articles