Great ! some instructions following. This assumes you already have a good grasp of Eclipse and have already used the Eclipse debugging interface before. There is nothing that much specific to modwsgi following actually, so I will be more or less paraphrasing what is written in http://pydev.org/manual_adv_remote_debugger.html
In order to debug your application running with modwsgi you need - Eclipse with Pydev (like Aptana from http://pydev.org/download.html) - your application already configured to run with modwsgi - read http://pydev.org/manual_adv_remote_debugger.html first Agenda: ----------- 1- debugging a singlethreaded application (single or multiple processes) on the server that runs Apache 2- debugging a multithreaded application 3- debugging from another host 1) debugging a singlethreaded application (single or multiple processes) on the server that runs Apache ----------- - in your Apache config, your WSGIDaemonProcess should be configured with threads=1 - add this at the top of your .wsgi file: import sys sys.path.append('/path/to/eclipse/plugins/ org.python.pydev.debug_1.6.../pysrc' ) import pydevd pydevd.settrace() - in the Eclipse Debug perspective, start the pydev server - run Apache and access your application You should already be able to fully use the Debugger from here. Since the debugger will suspend the program each time the settrace function is called, quickly it will be cumbersome to manually resume it for each process launched (especially if you're running like 20 processes), so if the above instructions worked so far, you can safely replace the settrace call with: pydevd.settrace(suspend=False) 2) debugging a multithreaded application: ----------- The following instructions are not complete, and I'm not fully happy with debugging multithreaded-application with this technique, but it does work if you absolutely need it (I would recommend to stick to the single thread-multi process though) ... let's get started - you need to have the settrace function called in each separate thread of the same application, but - do to badly synchronized code as reported here https://sourceforge.net/tracker/index.php?func=detail&aid=3135932&group_id=85796&atid=577329 , we're going to call it one more time in the main thread. Your .wsgi file will look like this: ( for example here for a Django app) import django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() pydevd.settrace() def application(environ, start_response): pydevd.settrace(suspend=False) return _application(environ, start_response) Here we ensure that the settrace is called for each threads, but from my current experience it does not work that well (accessing the application multiple times, it take several minutes to get it to suspend 2 different threads). Maybe it will work ok for you though - an alternative is to stick with the approach from 1) and set a low number of threads. You will be able to put breakpoints only on the main thread, but that should be enough to reproduce a race condition for example. 3) debugging from another host ----------- Assuming your apache server is running on a different box that the one you usually use to run Eclipse, what you need to do is: - ensure you can access the .wsgi and your application source code from both hosts (from a network drive for example) - copy the /path/to/eclipse/plugins/org.python.pydev.debug_1.6.../ pysrc to the box running Apache if it is not shared between the 2 boxes - edit the pydevd_file_utils.py file and locate the PATHS_FROM_ECLIPSE_TO_PYTHON variable. Set it to something like this: PATHS_FROM_ECLIPSE_TO_PYTHON = [ (normcase('Z:\\'),'/remote/pathto/yourhome/') ] - above we're launching Eclipse from Windows, the source code of the application and the wsgi are available under /remote/pathto/ yourhome/ on the Linux box running the Apache server, and those same sources are mounted through a samba drive on the Z: network drive under Windows (do not forget the \\ in the expression) Your thoughts ? -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
