我從瓶子應用程序中收到一個奇怪的「RuntimeError:調用Python對象時超出最大遞歸深度」。同時從wsgi句柄(在virtualenv中)運行它在openshift paas服務。從mod_wsgi句柄運行瓶子應用程序導致在調用Python對象時超出最大遞歸深度
回溯沒有提供我一個不好的事
我應該還提到,在我的開發MACHING(如蟒蛇pythonapp.py)運行腳本瓶直不正常工作的線索。
編輯:爲了驗證這個問題是連接到與mod_wsgi運行瓶我安裝它在我的開發計算機。運行直蟒作品。與mod_wsgi的運行讓我編輯的這個陌生的RuntimeError 末
我的問題#201 看到,這個問題已經「解決」,但可能用於其他用途的情況下
我用一瓶0.10.9上蟒蛇2.6 Linux服務器
Critical error while processing request: /about
Error: RuntimeError('maximum recursion depth exceeded while calling a Python object',)
Traceback:
Traceback (most recent call last):
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 824, in wsgi
out = self._cast(self._handle(environ), request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
File "path/to/app/virtenv/lib/python2.6/site-packages/bottle-0.10.9-py2.6.egg/bottle.py",
line 780, in _cast
return self._cast(out, request, response)
RuntimeError: maximum recursion depth exceeded while calling a Python object
的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)
我會很高興爲任何調試線索。
編輯:我嘗試設置遞歸限制較低,但只是失敗其他的事情(path.append,SQLAlchemy的等等),我起來,其他的事情失敗的水平以上(37準確地說)然後我得到此錯誤消息。當我被盯梢的錯誤日誌,我能夠生產另外2行錯誤堆棧之前去:
[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)
設置遞歸限制要低得多,以便我們可以看到是什麼調用。 – 2012-03-26 01:11:12
@ IgnacioVazquez-Abrams試過,似乎不是非常有用,但把它作爲編輯。 – alonisser 2012-03-26 22:05:59