gpt4 book ai didi

Visual Studio Code 中的 Python 异步/线程调试

转载 作者:行者123 更新时间:2023-12-03 07:34:07 29 4
gpt4 key购买 nike

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

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

其中一个模块是 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.........

并且同时
  • 变量 Pane 清除
  • 我的 watch 窗口中的 watch 显示:
    can0: not available

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

    问候,
    巴斯

    最佳答案

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

    关于Visual Studio Code 中的 Python 异步/线程调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43569165/

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