How does one use the VSCode debugger to debug a Gunicorn worker process?
<p>I have a GUnicorn/Falcon web service written in Python 3.4 on Ubuntu 14.04. I'd like to use the VSCode debugger to debug this service. I currently start the process with the command </p>

<pre><code>/usr/local/bin/gunicorn --config /webapps/connects/routerservice_config.py routerservice:api
</code></pre>

<p>which starts routerservice.py using the config file routerservice_config.py. I have workers set to 1 in the config to keep it simple.</p>

<p>I've installed the Python extension to VSCode so I have the Python debugging tools. So how do I attach to the GUnicorn worker process or have VSCode run the startup command and auto attach.</p>

<p>Thanks,
Greg</p>

<p>I'm the author of the extension.
You could try the following:
<a href="https://github.com/DonJayamanne/pythonVSCode/wiki/Debugging:-Remote-Debuging" rel="nofollow">https://github.com/DonJayamanne/pythonVSCode/wiki/Debugging:-Remote-Debuging</a></p>

<ul>
<li>Add the following code into your routerservice_config.py (or similar python startup file) 
<code>
import ptvsd
ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
</code></li>
<li>Start the above application</li>
<li>Go into VS Code and then attach the debugger</li>
</ul>

<p>FYI:<br>
- This requires you to include the ptvsd package and configure it in your application.<br>
- The plan is to add the feature to attach the debugger to any python process in the future (hopefully near future).  </p>

python debugging vscode gunicorn