Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从mod_wsgi handle运行瓶子应用程序会导致调用Python对象时超出最大递归深度_Python_Mod Wsgi_Bottle_Openshift - Fatal编程技术网

从mod_wsgi handle运行瓶子应用程序会导致调用Python对象时超出最大递归深度

从mod_wsgi handle运行瓶子应用程序会导致调用Python对象时超出最大递归深度,python,mod-wsgi,bottle,openshift,Python,Mod Wsgi,Bottle,Openshift,我从我的瓶子应用程序中得到了一个奇怪的“RuntimeError:调用Python对象时超过了最大递归深度”。在openshiftpaas服务中从wsgi句柄(在virtualenv中)运行它时 回溯并没有给我一点关于问题的线索 我还应该提到,在我的开发机器上直接运行瓶子脚本(例如pythonnapp.py)确实可以正常工作 编辑:为了验证此问题是否连接到使用mod_wsgi运行的瓶子,我在我的开发计算机上安装了它。直接运行python是可行的。使用mod_wsgi运行时会出现这种奇怪的运行时错

我从我的瓶子应用程序中得到了一个奇怪的“RuntimeError:调用Python对象时超过了最大递归深度”。在openshiftpaas服务中从wsgi句柄(在virtualenv中)运行它时

回溯并没有给我一点关于问题的线索

我还应该提到,在我的开发机器上直接运行瓶子脚本(例如pythonnapp.py)确实可以正常工作

编辑:为了验证此问题是否连接到使用mod_wsgi运行的瓶子,我在我的开发计算机上安装了它。直接运行python是可行的。使用mod_wsgi运行时会出现这种奇怪的运行时错误编辑结束

我看到了这件事 这个问题已经“解决”,但可能是另一个用例

我在linux服务器上使用Python2.6上的瓶子0.10.9

处理请求时出现严重错误:/about 错误:RuntimeError('调用Python对象时超出了最大递归深度',) 回溯: 回溯(最近一次呼叫最后一次): 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第824行,在wsgi中 out=self.\u cast(self.\u句柄(环境)、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) 文件“path/to/app/virtenv/lib/python2.6/site packages/battle-0.10.9-py2.6.egg/battle.py”, 第780行,内铸 返回自我。\u抛出(退出、请求、响应) RuntimeError:调用Python对象时超出了最大递归深度 WSGI句柄:

#!/usr/bin/python

import os
import sys
here = os.path.dirname(os.path.abspath(__file__))


try:
    os.environ['PYTHON_EGG_CACHE'] = os.path.join(os.environ['OPENSHIFT_APP_DIR'],'virtenv/lib/python2.6/site-packages')

except:
    os.environ['PYTHON_EGG_CACHE'] = os.path.join(here,'..','data/virtenv/lib/python2.6/site-packages')

print ('python egg cache set to: %s' % os.environ['PYTHON_EGG_CACHE'])
try:

    virtualenv = os.path.join(os.environ['OPENSHIFT_APP_DIR'],"virtenv/bin/activate_this.py")
except:
    virtualenv = os.path.join(here,'..',"data/virtenv/bin/activate_this.py")

print ('virtualenv is in:%s' % virtualenv)
try:
    execfile(virtualenv, dict(__file__=virtualenv))
    print ('executed')
    sys.path.append(here)

except IOError:
    pass

from myapp import application
myapp.py文件:

#!/bin/usr/env python
#-*- coding:UTF-8 -*-

from bottle import route,run, view, error, static_file, debug, url, redirect, request, response,  default_app

from wikifetch import init_db,load_session,Wikilink, statistic, wiki_populate
import bottle
from sqlalchemy.exc import StatementError
#from config import production_port, production_server
import json
debug(True)
bottle.TEMPLATE_PATH.append("./views")

init_db()
session = load_session()
try:
    stats = statistic()
except:
    print ("no data yet")
    pass

@route('/wsgi')
def show_ip():
    env = request.environ
    for k,v in env.items():
        print k,": ",v
    return env

@route()
def default():
    redirect("/monitor")

@route(["/monitor","/index","/"])
@view("monitor")
def monitor():
    title = request.query.title
    page = request.query.page or 0
    page = int(page)
    try:
        total = stats[0]
        all = session.query(Wikilink).filter(Wikilink.title.like('%'+ title +'%')).count()
        monitor = session.query(Wikilink).order_by('title').filter(Wikilink.title.like('%'+ title +'%')).offset(page*20).limit(20).all() #filter(Wikilink.id>(page*20))
        #print "page=",page," title=",title,
    except StatementError:
        session.rollback()
        #session.begin()

    #print monitor
    return dict(monitor=monitor,pages=(all/20),number=all,total = total)

@route("/why")
@view("why")
def why():
    return dict()

@route("/about")
@view("about")
def about():
    return dict()

@route("/learned")
@view("learned")
def learned():
    return dict()



@route("/stats")
@view("stats")
def statistic():
    return dict(stats= stats)

@route ("/static/<filepath:path>", name="static")
def static(filepath):
    #print 'yey', filepath
    return static_file(filepath,root = "./static/")


@error(404)
def error404(error):
    return static_file('404.html',root="./static")

#@error(502)
@error(500)
def error500(error):
    return static_file('500.html', root = "./static")

application = default_app()

if __name__ =='__main__':
    from wsgiref.simple_server import make_server #using the builtin wsgi server
    httpd = make_server('localhost', 8052, application)

您的代码正在触发错误处理程序,并且该处理程序似乎正在引发另一个错误

由于它在没有wsgi处理程序的情况下工作,因此触发初始错误的可能是路径问题。您可以尝试分解错误处理程序以查看瓶子错误页面,这可能会对问题有所帮助


通过调整处理程序中引发的错误,我注意到在
static()
函数中,您使用了关键字参数
root=“./static/”
,而在错误处理程序中,您省略了尾随斜杠。

将递归限制设置得更低,以便我们可以看到调用它的内容。@IgnacioVazquez Abrams尝试了这一点,似乎不是很有用,但将其作为编辑发布。我禁用了错误处理程序,但给出了相同的错误页。。我认为错误处理程序不是问题所在。你能详细谈谈我应该检查什么样的路径错误吗?@alonisser只是sys.path的内容,你导入的模块是否可以访问。wsgi处理程序通过
sys.path.append(此处)
以及调用virtualenv激活脚本来设置路径。您可以尝试直接运行wsgi处理程序,就像运行pythonapp.py脚本一样。只要在wsgi.py(或任何名称)的末尾添加相同的
,然后运行
python wsgi.py
。这应该与直接运行脚本相同,但是使用wsgi处理程序设置的路径。
[Mon Mar 26 14:50:52 2012] [error] no data yet #if you look in the code above - means that wikiwatch.py file passed the first 'stats' function

[Mon Mar 26 14:50:52 2012] [error] /home/usrname/workspace/appname/data/virtenv/lib/python2.6/site-packages/bottle.py:824: DeprecationWarning: Error handlers must not return :exc:`HTTPResponse`.
[Mon Mar 26 14:50:52 2012] [error]   out = self._cast(self._handle(environ), request, response)