PyCharm remote debugging
I have managed to set debug breakpoints on our Python Django server (running on apache). I didn't use "Django server" debug configuration, but "Python Remote Debug". I did so, because I am debugging a large Django project that I am less reluctant to mess with, and I rather just handle it as a "Python" project. Hopefully I can take that path.
Other than that - I set up the environment using the PyCharm's recommendations: I setup deployment server configuration + "Remote debugging" configuration with mapping, and on server loading I call:
sys.path.append('/home/cpmuser/debug/pycharm-debug.egg')
import pydevd
pydevd.settrace('localhost', port=21000, stdoutToServer=True, stderrToServer=True)
I used Putty to set up a reverse tunnel to make the code on the remote computer be able to connect the debugger. It should be part of pycharm's SSH features, but it isn't. PyCharm's internal SSH client could be very useful for that purpose (running SSH per debug session), but it does not support port forwarding needed to allow remote computer access the debugger (local machine).
This successfully helps catching breakpoints on server startup time - but not on further events (such as reloading the browser...) It simply wont stop in any break point anymore.
Any clue how to resolve that? It seems I have made everything that's needed for it to work, and there's only something tiny that blocks it from fully operating...
Please sign in to leave a comment.
Hi! The problem is that Djnago server usually creates new processes, and automatic attach to the new processes isn't supported in Remote Debug Server yet: https://youtrack.jetbrains.com/issue/PY-18541
Unfortunately, you should repeat your `pydevd.settrace()` call in child processes too.