GAE 1.7.7 PyDev debug problem

By Michael Kariv

  1. This document is published under this link:
  1. https://docs.google.com/document/d/1kF8UX9G6fvy5EzBujPwHtEB3bm7kcSHqSLiZHQ7KVNM/pub
  2. Short:
  1. http://goo.gl/XRU01
  1. I suggest for questions and suggestions to use StackOverflow thread
  1. http://stackoverflow.com/questions/15514743/pydev-breakpoints-in-app-engine-1-7-6-broken

The problem

  1. Working with Eclipse, debugging with PyDev, setting a breakpoint on one’s app (e.g. in main.py), debugger does not stop at a breakpoint
  2. The problem was reported in a number of forums
  1. http://stackoverflow.com/questions/15514743/pydev-breakpoints-in-app-engine-1-7-6-broken
  2. https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/ep5BWYKpQpU
  3. https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/TCQuJpF44cY
  4. https://code.google.com/p/appengine-devappserver2-experiment/issues/detail?id=28
  5. https://code.google.com/p/googleappengine/issues/detail?id=9012
  1. The workarounds suggested
  1. use old_dev_appserver.py
  2. don’t use breakpoints
  3. don’t use GAE at all
  1. I am kidding here but the first two workarounds were indeed propsed.

The hope

  1. Brain Quilan, a project member, posted his instructions on how to get PyDev work
  1. post in these  threads:
  1. https://code.google.com/p/appengine-devappserver2-experiment/issues/detail?id=28
  2. https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/TCQuJpF44cY
  1. post on March 11
  1. instructions document:
  2. https://docs.google.com/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit#heading=h.fj44xnkhr0gr
  3. aka http://goo.gl/3oSBp
  1. here is the important quotes from Brian Quilan
  1. I've started working on this and have written up a description of how I expect it to work: https://docs.google.com/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit?usp=sharing
  2. pdb doesn't work
  3. I have a prototype that works with Komodo IDE, PyDev, PyCharm
  4. I should add that the document that I linked in my last message is meant for tool providers, not end users. Hopefully tool provides will provide integration using these hooks without any the user have to know how they work.
  5. We have hooks in place to make it possible to add debugger support. It is up to tool vendors now to make use of them.
  1. So important things are 2 IMHO:
  1. It can be made to work here and now, Brian says he has a working prototype for DyDev
  2. In the future it will be made easy by the tool makers (PyDev makers), at least that is Brian’s plan.

Where I am trying to make it work

  1. I, Michael Kariv, am working to implement Brian’s instructions

Starting dev_appserver from eclipse

  1. In Eclipse I created a debug configuration for my project.
  2. Here are my arguments passed to dev_appserver.py
    --port=8080
    --admin_host=localhost
    --admin_port=8000
    --dev_appserver_log_level=debug
    --storage_path=C:\\tmp\\datastore\\
    --automatic_restart=no
    --python_startup_args={"port":7999}
    --python_startup_script=c:\\tmp\\pydevd_startup.py
    --max_server_instances=default:1
    ${workspace_loc:MyProject}
  3. An observation: breakpoints DO WORK if you set them in dev_appserver python code somewhere before an instance starts for your app.
  1. It does not help a developer but proves that PyDev debugger works fine in general.
  1. My pydevd_startup is indeed called just fine.
  1. It is impossible to set a breakpoint there
  2. The way I verified it being called is outputing a dummy print to a file
  1. I might have errors in my --python_startup_args={"port":7999
  1. JSON parsing was complaining
  2. I don’t care about it because I modded Brian’s pydevd_startup.py code to not read the port from configuraiton. I hard coded port into the script. Not good for a tool vendro, good enough for me trying to make things work.
  1. Here is my pydevd_startup.py code

import json, sys

pydev_path = r'C:\Users\kariv\.eclipse\org.eclipse.platform_4.2.0_1709980481\plugins\org.python.pydev_2.7.3.2013031601\pysrc'

sys.path.append(pydev_path)

import pydevd

pydevd.settrace('localhost', port=5678, stdoutToServer=False, stderrToServer=True)

  1. Notice is it much simpler that what Brian suggests in the document. I ignore port and other params. Taking care of the niceties like that will come later
  1. However within my hooked script I am unable to connect to pydev
  1. Debugger startup failed: [Errno 10061] No connection could be made because the target machine actively refused it
  1. Same thing happens for either port : 7999, 5678
  2. I suspect I miss a step. Someone needs to be listening on that port. Who?
  3. Trying now
  1. Obviously it is PyDev remote debugger
  2. http://pydev.org/manual_adv_remote_debugger.html
  3. Beware when you follow their instructions. Item 1 - clicking on a button - buttons are only visible in teh Debug mode. It is puzzling because Item 2 is - switch to Debug mode :). Someone was smoking something when writing this
    .
  1. I managed to hit a breakpoint in my hook script.
  2. However trying to debug leads to wierd conflicts. I suspect I can not run from pydev the dev_appserver. I think I need to run it from command line, using Eclipse/Pydev to remotely connect to an instance.

Starting dev_appserver from command line

  1. I do it the other way around now, and it makes sense to me, but still does not work.
  2. I start dev_appserver from a batch file that looks like Brian’s except it is all Windows bat file syntax

dev_appserver.py ^

--port=8080 ^

--admin_host=localhost ^

--admin_port=8000 ^

--dev_appserver_log_level=debug ^

--python_startup_script="c:\\Data\\cooknotebook\\tools\\pydevd_startup.py" ^

--storage_path="c:\\Data\\datastore\\" ^

--max_server_instances="default:1" ^

--python_startup_args="{""port"": 5678}" ^

--automatic_restart=no ^

app.yaml

  1. Here are my steps
  1. Start debug server for remote debugging from within eclipse,
  1.  following instructions here
  1. http://pydev.org/manual_adv_remote_debugger.html
  1. Once I start debug server, I see in Eclipse Console Debug Server:
  1. Debug Server at port: 5678

  1. Start dev_appserver from a batch file
  2. make a call to the localhost:8080
  1. either using a browser or
  2. using a fiddler2
  1. What I see is
  1. All the logging.* prints now go to Windows console from which I started the dev_appserver
  2. I stop within my hook script at the like dydevd.settrace as if there was a breakpoint
  3. I click to continue
  4. I see logging.* prints in Console within Eclipse !
  5. Unfortunately breakpoints still dont work


                                 

© 2013 Michael Kariv        GAE 1.7.7 PyDev debug problem Notes