How to combine "Remote debugging with the Python remote debug server configuration" and "Debug multithreaded applications"?

The doc examples are always nice and simple, but real life has these two combined. I am trying to remote debug a django app. I added the debugging code to the manage.py script of django, which looks like following:

#!/usr/bin/env python
import os
import sys

import pydevd_pycharm

pydevd_pycharm.settrace('192.168.254.50', port=12345, stdoutToServer=True,
                        stderrToServer=True)

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

 

This connects to the pycharm debugger but stays on the line 

execute_from_command_line(sys.argv)

and I don't see any further output. How can I attach the debugger to all the background processes which are getting started, like the daphne server or the channels asgi threads?

0
1 comment
Hi,
Which interpreter type do you use? If you use SSH interpreter, there's usually no need to use remote debug serever, as you can debug directly with the SSH interpreter https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html (it describes two ways of debugging).

If you must use remote debug serever -- it's not needed to run settrace() in the manage.py. You can place settrace() code into views and other code, and the debugger should connect as well.
0

Please sign in to leave a comment.