title: Attaching a VSCode Debugger to a Sub Process in Python
body: <p>I have a script that effectively does the following:</p>
  
  <p>top_script.py:</p>
  
  <pre><code>os.system("bash_script.sh")
  </code></pre>
  
  <p>bash_script.sh</p>
  
  <pre><code>python3 child_script.py
  </code></pre>
  
  <p>child_script.py</p>
  
  <pre><code># Actual work goes here
  </code></pre>
  
  <p>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". </p>
  
  <p>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.</p>
  
  <pre><code>python3 -m debugpy --listen 5678 top_script.py
  </code></pre>
  
  <p>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?</p>
  
  <p>[1] <a href="https://code.visualstudio.com/docs/python/debugging" rel="nofollow noreferrer">https://code.visualstudio.com/docs/python/debugging</a></p>