gpt4 book ai didi

python - 如何在uWSGI下调试python应用程序?

转载 作者:IT老高 更新时间:2023-10-28 21:53:06 25 4
gpt4 key购买 nike

当我尝试在 uWSGI 下使用 python pdb 调试器时,执行不会在断点处停止,它只是返回 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)。

如果您需要标准输入(就像您需要终端调试器时一样)添加:

--honour-stdin

关于python - 如何在uWSGI下调试python应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18427948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com