如何在uWSGI下调试python应用程序? [英] How to debug python application under uWSGI?

查看:44
本文介绍了如何在uWSGI下调试python应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 uWSGI 下使用 python pdb 调试器时,执行不会在断点处停止,它只是返回引用.

When I'm trying to use python pdb debugger under uWSGI, the execution doesn't stop on breakpoint, it just return trackback.

代码如下:

def application(env, start_response):
    import pdb; pdb.set_trace()
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"

这是我运行它的方式:

uwsgi --http 127.0.0.1:7777  --wsgi-file uwsgi_test.py

这就是我得到的:

/home/andrey/Development/ttt/uwsgi_test.py(3)application()
-> start_response('200 OK', [('Content-Type','text/html')])
(Pdb) 
Traceback (most recent call last):
  File "uwsgi_test.py", line 3, in application
    start_response('200 OK', [('Content-Type','text/html')])
  File "uwsgi_test.py", line 3, in application
    start_response('200 OK', [('Content-Type','text/html')])
  File "/usr/lib/python2.7/bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/lib/python2.7/bdb.py", line 67, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit
[pid: 11421|app: 0|req: 1/1] 127.0.0.1 () {32 vars in 366 bytes} [Sun Aug 25 13:12:06 2013] GET / => generated 0 bytes in 63 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

推荐答案

作为服务器,uWSGI 关闭了标准输入(实际上它重新映射到/dev/null).

Being a server, uWSGI closes the stdin (effectively it remaps it to /dev/null).

如果您需要 stdin(就像您需要终端调试器一样),请添加:

If you need stdin (as when you need a terminal debugger) add:

--honour-stdin

这篇关于如何在uWSGI下调试python应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆