Skip to content

Step Over, Step Into, not working when debugging Subprocesses #1876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maor-outrival opened this issue Mar 19, 2025 · 6 comments
Open

Step Over, Step Into, not working when debugging Subprocesses #1876

maor-outrival opened this issue Mar 19, 2025 · 6 comments
Assignees
Labels
needs repro Issue has not been reproduced yet Stale user responded

Comments

@maor-outrival
Copy link

maor-outrival commented Mar 19, 2025

When debugging a process in python, the program halts on breakpoints yet only the Continue button works. Pressing Step Over or Step into just Continues to the next breakpoint.

I have tried many launch.json configs and the only thing that resolved my issue was downgrading to v2024.10.0.

here is my config just in case:

    {
        "name": "Python Debugger: Current File",
        "type": "debugpy",
        "request": "launch",
        "program": "app/main.py",
        "console": "integratedTerminal",
        "env": {
            "PYTHONPATH": "${workspaceFolder}"
        },
        "justMyCode": true,
        "subProcess": true,
        "steppingResumesAllThreads": false
    },
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python-debugger Mar 26, 2025
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Mar 26, 2025
@rchiodo
Copy link
Contributor

rchiodo commented Mar 26, 2025

Can you share your application? This works fine for me with the latest bits.

DebugStepMultiproc.mp4

I used this code here:

import subprocess
import sys
import time

def act_busy():
    # Simulate a busy operation
    print("Subprocess is busy doing something...")
    for i in range(500):
        print(f"Working... {i + 1}/5")
        sys.stdout.flush()  # Ensure the output is flushed immediately
        time.sleep(1)  # Simulate work with a sleep

    print("Subprocess finished working.")

def run_subprocess():
    # Define the command to run as a subprocess
    command = ['python', __file__, 'act_busy']

    try:
        # Run the subprocess and wait for it to complete
        result = subprocess.run(command, capture_output=True, text=True, check=True)
        
        # Print the output of the subprocess
        print(result.stdout)
        
        # Print success message
        print("Subprocess completed successfully.")
    except subprocess.CalledProcessError as e:
        # Print error message if the subprocess fails
        print(f"Subprocess failed with error: {e}")

if __name__ == "__main__":
    if len(sys.argv) > 1:
        act_busy()
    else:
        run_subprocess()

Copy link

This issue was closed because it has been stalled for 30 days with no activity. If the issue still persists, please reopen with the information requested. Thanks.

@SobhanMP
Copy link

SobhanMP commented May 5, 2025

It's broken, see the following

import time
import multiprocessing as mp

def f():
    for i in range(10):
        time.sleep(1)
        print(i)

if __name__ == "__main__":
    p = mp.Process(target=f)
    p.start()
    p.join()

Image

@rchiodo
Copy link
Contributor

rchiodo commented May 5, 2025

Seems to work fine for me. Although I'm on windows.

DebugMultiproc.mp4

@rchiodo
Copy link
Contributor

rchiodo commented May 5, 2025

I can reproduce on Linux though.

@rchiodo rchiodo reopened this May 5, 2025
@rchiodo
Copy link
Contributor

rchiodo commented May 5, 2025

Strange but the subprocess example works fine on Linux. Not sure how multiprocess could affect stepping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet Stale user responded
Projects
None yet
Development

No branches or pull requests

4 participants