【问题标题】:Python asynchronous/threads debugging in Visual Studio CodeVisual Studio Code 中的 Python 异步/线程调试
【发布时间】:2017-09-20 00:25:49
【问题描述】:

我正在使用 Visual Studio Code 来编写我的 python 应用程序。如果我编写一个简单的同步单文件程序,检查变量和在左侧调试窗格中设置监视之类的东西就可以了。

但是,我在多个文件中有包含类的代码,并使用来自其他模块的各种回调。一些开始一个新的线程。

其中一个模块是 canopen 我可以单步执行我的代码,但是当我进入第二行时(如下)

can0 = canopen.Network()
can0.connect(channel='can0', bustype='socketcan')

然后调用堆栈从:

CALL STACK paused on breakpoint
main
<module>

CALL STACK paused on breakpoint
MainThread
Thread#15034.........

同时

  • 变量窗格清除
  • 我的手表窗口中的手表显示:

    can0: not available

我如何(使用 Python 设置 VS Studio 代码)使用各种线程和各种文件中的代码检查/调试我的 Python 代码?

问候, 巴斯

【问题讨论】:

    标签: python multithreading debugging visual-studio-code


    【解决方案1】:

    将调试设置为使用可视代码。

    你可以看到一篇关于如何设置调试器herehere的好文章,见:

    设置 "stopOnEntry":true 将导致调试器在 正在调试的 python 程序的第一行。如果这不是 需要,然后将值从 true 更改为 false。默认值 这个设置是真的。

    【讨论】:

      【解决方案2】:

      新的调试器能够调试异步应用程序。 查看如何设置 How to update ptvsd used by Visual Studio Code in debug mode 并且不要忘记在launch.json中添加“subProcess”:true

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-21
        • 2018-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-25
        • 2016-12-29
        相关资源
        最近更新 更多