I don't think this issue is unique to PyDev, but to any python debugger.
Using Eclipse and pydev, I'm unable to break on my WSGI handler, in a dev_appserver (The Google app engine development server) process. I'm not 100% sure, but I think this is a regression in GAE 1.7.6 or 1.7.7, as I'm almost certain I was able to debug my code before I upgrade to 1.7.7
It appears that GAE creates a new process ('_python_runtime.py') which isn't controlled by PyDev. I couldn't find any evidence that 'debugging subprocesses' feature is available in PyDev, so right now I'm a little bit lost.
Looking at the GAE code (1.7.7) it appears the subprocess is created in tools/devappserver2/http_runtime.py which calls safe_subprocess.py/start_process
.
Goofing around I didn't see any obvious method to either:
1. Tell GAE to server to user handler from the same process.
2. Tell GAE to change the command line of the new project from python _python_runtime.py
to python pydev.py ... --file _python_runtime.py
(and even then, not sure PyDev will be able to pick it up).
Any suggestion? Is that really a regression?
EDIT (partial answer):
Here is a partial answer. IN SDK 1.7.6 Google App Engine has a completely new server. The server is now a multi-process. The main process spawns sub-processes (called runtime) to run the WSGI handlers. These sub-processes aren't being debugged.
This change caused a lot of reaction in the community, but apparently the GAE community mainly lives in the Google Groups and not in SO (something I wasn't aware of until yesterday). Here is a link to the discussion:
https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/ep5BWYKpQpU
There are basically two solutions:
The simple thing to do would be to use the old server, which as of 1.7.7 is still available. Instead of dev_appserver.py, simply launch old_dev_appserver.py. In Eclipse PyDev, go to Debug Configuration..., and replace the 'Main Module' to $(GOOGLE_APP_ENGINE)/old_dev_appserver.py, and launch as if the new server never happened. This solution has obviously the drawback of running an older server, and it is unknown how long this setting is going to be maintained.
The second solution is a little bit more involving, and I wasn't able to crack it all the way yet. It is based on remote debugging feature of PyDev, and the ability to tell GAE to run a script at the beginning of the runtime process. So this is how to do it:
# gae_runtime_startup.py
import pydevd;
pydevd.settrace()
Some related links:
That was indeed a regression that was fixed in 1.8.3: https://code.google.com/p/googleappengine/wiki/SdkReleaseNotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With