when I connect my vs code debugger to my python container, everything works, but when I press restart on the debugger panel, fastapi restarts (I can see in the docker logs) but the debugger no longer works
this is the command in compose:
当我将我的VS代码调试器连接到我的Python容器时,一切都正常,但当我按下调试器面板上的重新启动时,fast api重新启动(我可以在docker日志中看到),但调试器不再工作。这是Compose中的命令:
pip install debugpy -t /tmp && python -Xfrozen_modules=off /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
and launch.json:
和Launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
]
}
]}
the debugger panel on the left shows that the server process restarted but I can't continue, yet when I make a file change, stat reloads,'Shutting down' logs appears, and then I can again interact with the debugger panel.
Is this a bug? Do I have to add a config as to what happens when I click the restart button?
左侧的调试器面板显示服务器进程已重新启动,但我无法继续,但当我更改文件、重新加载统计数据时,会出现正在关闭的日志,然后我可以再次与调试器面板交互。这是个窃听器吗?当我点击重新启动按钮时会发生什么,我需要添加配置吗?
更多回答
OK turns out I was putting my breakpoints in main.py, and the first run from compose, with the flag -Xfrozen_modules=off, let me debug main.py, but on restart, the flag seems to not be applied, therefore I cant breakpoint there. any idea to guarantee this flag always?
OK原来我把断点放在main.py上,第一次从compose运行时,标志-Xfrozen_modules=off,让我调试main.py,但在重新启动时,标志似乎没有应用,因此我不能在那里断点。有什么办法可以保证这面旗帜永远不变吗?
我是一名优秀的程序员,十分优秀!