microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
56 stars 23 forks source link

Debugger Dies in Multiprocessing Env #178

Open 95anantsingh opened 8 months ago

95anantsingh commented 8 months ago

Type: Bug

Behaviour

Expected vs. Actual

Launching a debugger instance when multiprocessing is involved causes the debugger to exit without any error. When process.join() is added to the code it works fine but not without it.

Steps to reproduce:

Add a breakpoint at time.sleep(5) line and wait few seconds

import time
from multiprocessing import Process

class MyClass:

    def run(self):
        process = Process(target=self.launch)
        process.start()
        # process.join()

    def launch(self):
        print("Started")
        time.sleep(5) # Try to add breakpoint at this line
        print("Finished")

if __name__ == "__main__":
   obj = MyClass()
   obj.run()

Diagnostic data

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

``` 2024-01-19 21:34:43.647 [info] Using launch configuration in workspace folder. 2024-01-19 21:34:43.730 [info] DAP Server launched with command: /opt/homebrew/bin/python3.12 /Users//.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter 2024-01-19 21:34:43.828 [info] Send text to terminal: cd /Projects/Dummy ; /usr/bin/env /opt/homebrew/bin/python3.12 /Users//.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 62517 -- /Projects/Dummy/test.py 2024-01-19 21:34:44.300 [info] Connecting to DAP Server at: 127.0.0.1:62515 2024-01-19 21:34:44.311 [info] Connecting to DAP Server at: 127.0.0.1:62515 ```

User Settings

``` languageServer: "Pylance" ```

Extension version: 2023.22.1 VS Code version: Code 1.85.2 (Universal) (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:32.531Z) OS version: Darwin arm64 23.2.0 Modes: Connection to 'attached-container+7b22636f6e7461696e65724e616d65223a222f6a756e6f2d646576222c2273657474696e6773223a7b22636f6e74657874223a226465736b746f702d6c696e7578227d7d' could not be established

System Info |Item|Value| |---|---| |CPUs|Apple M2 Pro (12 x 24)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (0.33GB free)| |Process Argv|--crash-reporter-id fc29a4f7-357a-4d7f-83aa-04d4ff4a2ca6| |Screen Reader|no| |VM|0%| Connection to 'attached-container+7b22636f6e7461696e65724e616d65223a222f6a756e6f2d646576222c2273657474696e6773223a7b22636f6e74657874223a226465736b746f702d6c696e7578227d7d' could not be established
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 vsclangdc:30486549 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 0bi6i642:30933247 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 pythontbext0:30879054 accentitlementst:30887150 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 dsvsc019acf:30933242 ```
### Tasks
paulacamargo25 commented 3 months ago

Thanks for the bug report and sorry for the delay, could you send me your launch.json configuration? Thanks

vs-code-engineering[bot] commented 1 week ago

Hey @karthiknadig, this issue might need further attention.

@95anantsingh, you can help us out by closing this issue if the problem no longer exists, or adding more information.

95anantsingh commented 1 week ago

@karthiknadig @paulacamargo25 @vs-code-engineering

I used the default launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}