Debugging with pdb hangs on Windows

36 views
Skip to first unread message

booltype

unread,
Feb 1, 2012, 12:18:08 AM2/1/12
to modwsgi
Hi,
I am having troubles getting pdf interactive debugging to work on a
Django project I have to support, running on Windows.

I can start httpd.exe -X from the command line with the standard setup
ok, but if I try to wrap the application in Debugger() a reload of the
page hangs and times out. No change at the command line (i.e. PDB
showing).

One thing I noticed is that I cannot stop httpd.exe with CTRL-C at the
command line and have to close cmd.exe directly - not sure if that is
relevant.

Is the wrapped call as I did even possible with Django? Or any
pointers as to how to get this running?


Thanks
Stefan



Software versions:
==================
- Windows XP SP3
- Apache 2.2.1 (apache.org download)
- mod_wsgi 3.3 (binary download from mod_wsgi home)
- Python 2.7.2 (from python.org)


mod_wsgi configuration
======================
As far as I can tell mod_wsgi is not configured further in the Apache
conf files (just a LoadModule), running in embedded mode (verified as
described in http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode)


django.wsgi
===========

import os, sys

class Debugger:

def __init__(self, object):
self.__object = object

def __call__(self, *args, **kwargs):
import pdb, sys
debugger = pdb.Pdb()
debugger.use_rawinput = 0
debugger.reset()
sys.settrace(debugger.trace_dispatch)

try:
return self.__object(*args, **kwargs)
finally:
debugger.quitting = 1
sys.settrace(None)



#Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)

#Add the path to 3rd party django application and to django itself.
sys.path.append('d:\\project')
sys.path.append('d:\\project\\python27\\Lib\\site-packages\\django')
sys.path.append('d:\\project\\python27\\Lib\\site-packages\\django')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
import django.core.handlers.wsgi
application = Debugger(django.core.handlers.wsgi.WSGIHandler())

Graham Dumpleton

unread,
Feb 1, 2012, 8:32:42 PM2/1/12
to mod...@googlegroups.com
That recipe was only ever tested on UNIX systems. I wouldn't be surprised if it didn't work on Windows. It may be necessary to use a more capable debugger such as that in Komodo IDE which allows remote debugging of process without needing to start Apache in that funny way.

Hard for me to suggest much else right now. If you have a specific issue with code that might be caused by running under mod_wsgi then you could always explain it as can see if know about issue already.

Graham
> --
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>
>
Reply all
Reply to author
Forward
0 new messages