I have a script that effectively does the following:
top_script.py:
os.system("bash_script.sh")
bash_script.sh
python3 child_script.py
child_script.py
# Actual work goes here
In VSCode, I love the integrated debugger, but when I follow their advice[1] when launching from the IDE, I get "ECONNREFUSED 127.0.0.1:5678".
When I execute the following from the integrated terminal in VSCode, it runs without the errors, but it doesn't stop on breakpoints in child_script.py.
python3 -m debugpy --listen 5678 top_script.py
How can I execute the top script first (either from the IDE or command line) and have breakpoints I attach in child_script.py be rendered in VSCode?
[1] https://code.visualstudio.com/docs/python/debugging
You can add a configuration to your launch.json file like the following:
{
"name": "MySubProcess",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}"
}
Now start your python process separately (via a prompt, or however). This will generate a python subprocess. You can see this in Windows Task Manager (or also in MacOS Activity monitor, or in Linux a similar way).
In VSCode, then click Debug, (select your subprocess configuration: "MySubProcess" in our example above), and then choose the process which was just started. The debugger will then stop at the breakpoints in your subprocess code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With