1

I'm running into an issue trying to run my python web app on EB. It runs fine locally, but I get the following exception when I run it on EB. The problem seems to be that it runs into an exception, but the stack trace is of an error that occurs after that original one, so I can't really determine what the root cause is:

Exception on /admin GET
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1817, in     wsgi_app
response = self.full_dispatch_request()
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1477, in     full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1475, in     full_dispatch_request
rv = self.dispatch_request()
File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionshttp://rule.endpoint(**req.view_args)
File "/opt/python/run/venv/lib/python2.7/site-packages/sandman/sandman.py", line 459, in get_collection
cls = endpoint_class(collection)
File "/opt/python/run/venv/lib/python2.7/site-packages/sandman/sandman.py", line 185, in endpoint_class
cls = current_app.class_referencescollection
File "/opt/python/run/venv/lib/python2.7/site-packages/werkzeug/local.py", line 338, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: 'Flask' object has no attribute 'class_references'

When I manually start the app on port 5000 after SSHing into my instance, and attempted to load the same page from the console, I did not get any error (and the saved file contained the correct HTML):

wget http://127.0.0.1:5000/admin
--2014-03-23 17:01:13-- http://127.0.0.1:5000/admin
Connecting to 127.0.0.1:5000... connected.
HTTP request sent, awaiting response... 127.0.0.1 - - 23/Mar/2014 17:01:13 "GET /admin     HTTP/1.1" 301 -
301 MOVED PERMANENTLY
Location: http://127.0.0.1:5000/admin/ following
--2014-03-23 17:01:13-- http://127.0.0.1:5000/admin/
Connecting to 127.0.0.1:5000... connected.
HTTP request sent, awaiting response... 127.0.0.1 - - 23/Mar/2014 17:01:13 "GET /admin/     HTTP/1.1" 200 -
200 OK
Length: 1519 (1.5K) text/html
Saving to: ‘admin’

this is the python app code I'm running: http://pastebin.com/qgnWz6aK

2
  • Did you check whether the Python / Flask / Werkzeug versions match what you have locally? Commented Mar 24, 2014 at 11:00
  • Python is 2.7 on local & the server. The flask and werkzeug versions are defined in the requirements.txt file by Pip, so those are also the same. Commented Apr 1, 2014 at 14:48

1 Answer 1

1

I managed to work around this issue by using Tornado (though I'm still not sure what the underlying issue is):

from sandman import app
from sandman.model import activate
import logging
import os, sys
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DB']

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    activate(browser=False)
    app.debug = True
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(os.environ['PORT'])
    IOLoop.instance().start()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.