调试Python时将Stack调用为空

问题描述

我正在使用VSCode和Python扩展在Python中的多线程项目中工作。 一切正常,直到突然之间,无需更改任何设置)就停止在“调用堆栈”中显示正在运行的进程和线程。调用堆栈现在为空,直到它在断点处停止为止。

这仅适用于Python。例如,对于C ++,它可以正常工作,如下图所示:

c++ call stack; showing running threads

在这里关注我的配置文件

settings.json:

{
    "python.pythonPath": "C:\\Users\\tiago\\AppData\\Local\\Programs\\Python\\python38\\python.exe","python.linting.pylintEnabled": false,"python.linting.enabled": true,"python.linting.pylamaEnabled": false,"python.linting.Flake8Enabled": true
}

launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more @R_990_4045@ion,visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0","configurations": [
        {
            "name": "Python: Current File","type": "python","request": "launch","program": "${file}","console": "externalTerminal"
        }
    ]
}

解决方法

之所以发生这种情况,是因为我将' GEVENT_SUPPORT '环境变量设置为 True ,并且as @fabioz said是这样的:“在gevent模式下,调试器期望线程化gevent会用猴子修补模块,因此它不会跟踪这些模块(如在gevent模式下,您只希望有1个主线程)。“