[英]Debugging python hug api with pdb
I'm trying to debug a python hug API with pdb
. 我正在尝试使用
pdb
调试python hug API。
The regular hug api is started with: hug -f api.py
常规的拥抱api以以下内容开头:
hug -f api.py
You can start pdb from the command line via python
interpreter using: 您可以使用以下命令通过
python
解释器从命令行启动pdb:
python -m pdb api.py
Where api.py
contains hug routes, directives etc. api.py
however needs to be run with hug -f api.py
which doesn't accept -m pdb
. 其中
api.py
包含拥抱路线,指令等。但是api.py
需要与不接受-m pdb
hug -f api.py
运行。
eg: hug -m pdb -f api.py
doesn't work. 例如:
hug -m pdb -f api.py
不起作用。
I also tried creating a debug.py
file and import api.py
into it with debugging started. 我还尝试创建
debug.py
文件,并在调试开始时将api.py
导入其中。 But it doesn't register the routes in api.py
. 但是它没有在
api.py
注册路由。
import pdb
from api import *
@hug.startup()
def startup(args):
"""Starts api and debugging"""
pdb.set_trace()
The hug server starts ok, but without any routes defined in api.py
. 拥抱服务器启动正常,但没有在
api.py
定义任何路由。
At the moment I'm resorting to having to put pdb.set_trace()
directly into one of the routes in api.py
. 目前我诉诸不必把
pdb.set_trace()
直接进入的途径之一api.py
。 This works but is tedious. 这可行,但很乏味。 Ideally there should be a way to start
api.py
with hug
and pdb
debugging and set breakpoints dynamically without restarting hug
. 理想情况下,应该有一种方法可以通过
hug
和pdb
调试来启动api.py
并动态设置断点而无需重新启动hug
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.