无法在Google App Engine中调试dev_appserver [英] Unable to debug dev_appserver in Google App Engine

查看:300
本文介绍了无法在Google App Engine中调试dev_appserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不认为这个问题是PyDev独有的,而是任何python调试器。



使用Eclipse和pydev,我无法打破我的WSGI处理程序,在dev_appserver(Google应用程序引擎开发服务器)进程中。我不是100%确定的,但我认为这是GAE 1.7.6或1.7.7的回归,因为我几乎可以确定在升级到1.7.7之前我能够调试我的代码。



GAE似乎创建了一个不受PyDev控制的新进程('_python_runtime.py')。我找不到任何证据表明'调试子进程'功能在PyDev中可用,所以现在我有点失落。



查看GAE代码( 1.7.7)看来子进程是在tools / devappserver2 / http_runtime.py中创建的,它调用 safe_subprocess.py/start_process



瞎搞我没有看到任何明显的方法:
1.告诉GAE服务器到用户处理程序从相同的过程。
2.告诉GAE将新项目的命令行从 python _python_runtime.py 更改为 python pydev.py ... - -file _python_runtime.py (即使如此,不知道PyDev能够捡起它)。



任何建议?这真的是一个回归?



编辑(部分答案):

这是部分答案。 IN SDK 1.7.6 Google App Engine有一个全新的服务器。服务器现在是一个多进程。主进程派生子进程(称为运行时)来运行WSGI处理程序。这些子流程没有被调试。



这个变化在社区中引起了很多反响,但显然GAE社区主要生活在Google Groups中,而不是所以(直到昨天我才知道)。以下是讨论的链接:



https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/ep5BWYKpQpU



基本上有两种解决方案:


  1. 简单的做法是使用旧服务器,从1.7.7开始仍然可用。而不是dev_appserver.py,只需启动old_dev_appserver.py即可。在Eclipse PyDev中,转到Debug Configuration ...,并将'Main Module'替换为$(GOOGLE_APP_ENGINE)/old_dev_appserver.py,并启动,就好像新的服务器从未发生过一样。此解决方案明显存在运行旧服务器的缺点,并且未知该设置将维持多久。



  2. 第二个解决方案涉及更多一点,而且我还没有完全破解它。它基于PyDev的远程调试功能,并能够告诉GAE在运行时流程开始时运行脚本。所以这是如何做到的:



    1. 创建一个脚本并将其命名为:gae_runtime_startup.py。 Put在全局PyDev首选项(窗口菜单 - >首选项 - > PyDev - >解释器Python - >字符串替换变量中,添加一个新的PYDEV变量,并设置值到Eclipse的PyDev插件(在我的电脑中,这是c:\ eclipse \plugins\org.python.pydev_2.7.1.2012100913)。 将$ {PYDEV} / pysrc添加到PYTHONPATH中,这样,您就可以使用pydevd

    2. 您需要告诉GAE运行gae_runtime_startup.py。转到Launcher,然后将以下选项添加到命令行(调试配置 - >参数):--python_startup_script =<完整路径> /gae_runtime_startup.py --max_server_instances = 1

    3. 开始PyDev远程服务器。



    因此,在完成所有这些之后,我在运行时进程的runtime_startup.py中得到一个断点。在堆栈中,我将在runtime.py源代码中进行操作 - 所以我认为我的方向是正确的然而,我在我的处理程序中设定的断点不会中断 - 所以这条路线对我来说仍然受阻。任何帮助将不胜感激。



 #gae_runtime_startup.py 
import pydevd;
pydevd.settrace()

一些相关链接:

  • Google小组讨论: https://code.google.com/p / appengine-devappserver2-experiment / issues / detail?id = 28

  • 解释如何调试的文档(我的第二种方法):https://docs.google.com/a/london.org.il/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit

  • PyDev的一个文档,解释了如何设置远程调试器。 http://pydev.org/manual_adv_remote_debugger.html

  • 另请参见@ Tim Hoffman below。

    解决方案

    这确实是一个在1.8.3中修复的回归: https://code.google.com/p/googleappengine/wiki/SdkReleaseNotes


    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:

    1. 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.

    2. 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:

      1. Create a script and name it: gae_runtime_startup.py. Put is somewhere (below).
      2. In global PyDev preferences (Window menu -> Preferences -> PyDev -> Interpreter Python -> String Substitution Variables, add a new PYDEV variable, and set the value to the PyDev plugin of eclipse (In my computer this is c:\eclipse\plugins\org.python.pydev_2.7.1.2012100913).
      3. In the project property, add ${PYDEV}/pysrc to the PYTHONPATH. This way, you'll be able to impord pydevd
      4. You need to tell GAE to run gae_runtime_startup.py. Go to the Launcher, and add the following options to the command line (Debug Configurations -> Arguments): --python_startup_script=<full path>/gae_runtime_startup.py --max_server_instances=1
      5. Start the PyDev remote server.

      So, after doing all that, I get a break point within runtime_startup.py running on the runtime process. If I go up the stack, I'll step within the runtime.py sources - so I think I'm in the right direction. And yet, the breakpoints I set in my handlers to not break - so this route is still blocked for me. Any help will be appreciated.

    # gae_runtime_startup.py
    import pydevd; 
    pydevd.settrace()
    

    Some related links:

  • Google Group discussion: https://code.google.com/p/appengine-devappserver2-experiment/issues/detail?id=28
  • A document from Google explaining how to debug (my second method): https://docs.google.com/a/london.org.il/document/d/1CCSaRiIWCLgbD3OwmuKsRoHHDfBffbROWyVWWL0ZXN4/edit
  • A document from PyDev explaining how to set remote debugger. http://pydev.org/manual_adv_remote_debugger.html
  • See also excellent comment from @Tim Hoffman below.

    解决方案

    That was indeed a regression that was fixed in 1.8.3: https://code.google.com/p/googleappengine/wiki/SdkReleaseNotes.

    这篇关于无法在Google App Engine中调试dev_appserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆