remote debugging of uwsgi django application

Hi there!

in short

I'm Unable to use the "remote debugging" feature in my setup:
remote debugging is set up according to the documentation, but the breakpoints are never reached/stopped at.

The setup

above pycharm version, (tried EAP 2.7 too, but this seems a principle problem), OS: linux 64 bit.
I'm trying to debug python django code on a remote machine, which is uWSGI server running python2.6 in virtualenv, with the following setup details in uwsgi's .ini file [essential parts]:

threads = 125
socket-timeout = 8


On PyCharm side I am launching debug server, and can see:

Waiting for connection...
Starting debug server at port 54322


In my code the following code is implanted:

add_pydev_egg_to_syspath() # this one inserts the egg full path into sys.path list
from pydev import pydevd
pydevd.settrace(server_ip,port=port,stdoutToServer=True,stderrToServer=True) # the port/IP are correct


I've tried putting the above code in the following places in the app:
  • in the .wsgi script launched by uWSGI server
  • at the top of the views.py file processing the request I'm debugging
  • above the method processing the request I'm debugging
  • inside the method processing the request I'm debugging

Also, I tried suspend=True or False.

After the code deployment uwsgi log shows:

PyDev console: using IPython 0.12

Following that, PyCharm debug server console shows:

Connected to pydev debugger (build 121.378)


The problem as I mentioned is: the breakpoint is NEVER reached + highlighted.


I suspect the problem is with the fact there are several threads on the server side, and pydev does not allow multiple connections,
so even though 1 thread has connected to the pydev console, the thread actually responding to the request - either fails to connect or is simply ignored, even though it has a connection details.


Questions:
Where do I proceed further ?


Thanks!!!!
0
1 comment
I know this is an ancient thread, but there is very little on this topic, and I finally found a solution, so here it is:

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
_application = django.core.handlers.wsgi.WSGIHandler()



def application(environ, start_response):
    pydevd.settrace('192.168.1.145', port=8999, stdoutToServer=True, stderrToServer=True, suspend=False)
    return _application(environ, start_response)


This is the wsgi script. Note the suspend=False on the settrace. And that this setttrace needs to go inside the application, not after it!
0

Please sign in to leave a comment.