Note that there are some explanatory texts on larger screens.

plurals
  1. POrunning a bottle app from mod_wsgi handle results in maximum recursion depth exceeded while calling a Python object
    primarykey
    data
    text
    <p>I'm getting a strange "RuntimeError: maximum recursion depth exceeded while calling a Python object" from my bottle app. while running it from a wsgi handle (inside a virtualenv) in <strong>openshift</strong> paas service. </p> <p>the traceback doesn't offer me a clue about what's wrong</p> <p>I should also mention that running the bottle script straight on my dev maching (e.g python pythonapp.py) does work properly.</p> <p><strong>edit:</strong> In order to verify this problem is connected to running bottle with mod_wsgi I installed it on my dev computer. running straight python works. running with mod_wsgi gives me this strange RuntimeError <strong>end of edit</strong></p> <p>I saw in issue <a href="https://github.com/defnull/bottle/commit/882668ff342e89d6d91fb4138b8546632946d571" rel="nofollow">#201</a> that this problem was already "solved" but probably for another use case</p> <p>I'm using bottle 0.10.9 on python 2.6 in a linux server </p> <pre class="lang-none prettyprint-override"><code>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 </code></pre> <p>The WSGI handle:</p> <pre><code>#!/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 </code></pre> <p>the myapp.py file:</p> <pre><code>#!/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&gt;(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/&lt;filepath:path&gt;", 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) </code></pre> <p>I would be glad for any debugging clue.</p> <p><strong>edit:</strong> I tried setting the recursion limit lower but that just fails other things (path.append, sqlalchemy etc..) when I rise above the level that other things fail (37 to be precise) then I get this error message. when I tailed the error log I was able to produce another 2 lines that go before the error stack:</p> <pre><code>[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) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload