debugging VsCode中的多个python远程连接

9bfwbjaz  于 2023-03-13  发布在  Vscode
关注(0)|答案(1)|浏览(141)

我有一个包含多个服务的docker-compose堆栈,其中有3个容器使用了python:瓶celery Worker 1celery Worker 2
我使用debugpy和Python远程附加从VsCode调试,与此launch.json:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Remote Attach",
      "type": "python",
      "request": "attach",
      "connect": { "host": "0.0.0.0", "port": 6900 },
      "pathMappings": [
        {
          "localRoot": "/path/to/celeryworker1/app",
          "remoteRoot": "/app"
        },
      ],
      "justMyCode": true
    },
  ]
}

当我调试一个容器的时候,这是很好的,但是我的容器是一起工作的,我需要在我所有的容器中放置一些断点。
我尝试添加配置

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Remote Attach",
      "type": "python",
      "request": "attach",
      "connect": { "host": "0.0.0.0", "port": 6900 },
      "pathMappings": [
        {
          "localRoot": "/path/to/celeryworker1/app",
          "remoteRoot": "/app"
        },
      ],
      "justMyCode": true
    },
    {
      "name": "Python: Remote Attach",
      "type": "python",
      "request": "attach",
      "connect": {
        "host": "0.0.0.0",
        "port": 6901
      },
      "pathMappings": [
        {
          "localRoot": "/path/to/celeryworker2/app",
          "remoteRoot": "/app"
        }
      ],
      "justMyCode": true
    },
    ...
  ]
}

我有
pydev debugger: unable to find translation for: "/path/to/celeryworker2/app/app.py" in ["/path/to/celeryworker1/app", "/path/to/celeryworker1/app"] (please revise your path mappings)

uqxowvwt

uqxowvwt1#

{
  "configurations": [
    {
      "name": "celeryworker1",
      ...
    },
    {
      "name": "celeryworker2",
      ...
    },
    ...
  ]
}

我自己找到的解决方案,我设置了两个相同的名称在我的配置。工作良好,现在当我启动两个调试器。

相关问题