Skip to content

Python debugger under attach mode randomly connect a vscode instance #632

@ytwanghaoyu

Description

@ytwanghaoyu

Type: Bug

Behaviour

I have my python debugpy config set like this:

  {
    "name": "Python: Attach",
    "type": "debugpy",
    "request": "attach",
    "connect": {
      "host": "localhost",
      "port": 5678
    }

And when I open like 2 vscode window, and it just randomly attach to one of them, and raise an error on the other one.

Error: Server[pid=****] is already being debugged.

Possible additional info for you to debug:

  1. My debug config is saved in setting.json as global synced config.

  2. My python version is 3.8.10

  3. Before this error happens, I need to manually press F5 to attach to my program, but at some time (At least two months ago) It just automatically attached to my vscode debugger.

  4. In the code I use a code like this to wait for debugpy attaching

     import debugpy
    
     debugpy.listen(port)
     print('\033[91m' + 'Waiting for debugger attach' + '\033[0m')
     debugpy.wait_for_client()
     print('\033[92m' + 'Debugger attached' + '\033[0m')
    

Steps to reproduce:

  1. Just open more than one vscode window, and use debugpy to attach to your running program

Diagnostic data

launch.json configuration

XXX

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Output for Python Debugger in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Debugger)

XXX

Extension version: 2025.1.2025022401
VS Code version: Code 1.97.2 (e54c774e0add60467559eb0d1e229c6452cf8447, 2025-02-12T23:20:35.343Z)
OS version: Linux x64 5.15.0-67-generic
Modes:
Remote OS version: Linux x64 5.15.0-130-generic

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Unknown
System Info
Item Value
CPUs Intel(R) Xeon(R) W-2245 CPU @ 3.90GHz (16 x 1288)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 3, 3, 2
Memory (System) 125.50GB (86.61GB free)
Process Argv
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions