Closed maralad closed 7 years ago
What is in your zappa settings, particularly the app function?
The only thing I got regarding settings is the zappa_settings.json created by zappa init. so like this.. { "dev": { "django_settings": "visualid.settings.py", "s3_bucket": "mybucketnameishere" } }
I haven't played with the django integration yet but I expect the .py is being used as a file name. Try taking that off so zappa can import your settings using that as the import path and see if that helps.
Thanks for the suggestion, I tried that but that makes no difference. Do I need some other settings in my settings.py for zappa?
Did you find a solution yet? I am getting the same error (without django).
My zappa_settings.json
:
{
"dev": {
"aws_region": "us-east-1",
"app_function": "my_app.app",
"s3_bucket": "myproject-lambda",
"profile_name": "myproject"
}
}
When I remove everything but a hello world from the python file it works fine and the response is returned. If I import a module that was not installed via pip into the module that contains the WSGI application I get the same error message. The same WSGI application runs fine with uWSGI or gunicorn. Any ideas how to fix this?
I got it working. you have to also include the middleware settings. basically follow these instructions. . https://serverlesscode.com/post/zappa-wsgi-for-python/
Hi all, I have a flask app deployed in lambda. The versions i am using are
flask==0.11
zappa==0.28.2
-----Other dependency----
flask-cors==3.0.2
Flask-SQLAlchemy==2.1
Flask-Markdown==0.3
Flask-Gravatar==0.4.2
boto3==1.4.3
flasgger==0.5.13
python-dotenv==0.6.0
PyJWT==1.4.2
Flask-Migrate==2.0.0
Flask-Script==2.0.5
psycopg2==2.6.2
flask-s3==0.3.1
blinker==1.4
enum34==1.1.6
gevent==1.2.1
Most of the time the app serves the api request perfectly. But sometimes it is throwing this error and then i have to redeploy the whole app and then it starts working again. My zappa configuration is:
{
"stage": {
"project_name": "dpr-api",
"s3_bucket": "",
"app_function": "dpr.application",
"aws_region": "us-west-2",
"use_apigateway": true,
"memory_size": 512,
"log_level": "DEBUG",
"debug": true,
"profile_name": "default",
"cloudwatch_log_level": "DEBUG",
"cloudwatch_data_trace": true,
"cloudwatch_metrics_enabled": true,
"delete_local_zip": true,
"delete_s3_zip": true,
"environment_variables": {
"FLASK_CONFIGURATION": "stage"
}
}
}
The entry point of the application is, dpr.py
# -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
from app import create_app
application = create_app()
if __name__ == "__main__":
from gevent.wsgi import WSGIServer
http_server = WSGIServer(('', 5000), application)
http_server.serve_forever()
The WSGIServer
i am using for local running.
Anything i am doing wrong, or it is lambda specific issue?
Thanks, subhankar
This can be easily reproduced.
django-admin.py startproject testzappa
zappa init
.zappa deploy
.I consistently see the above error, even after repeated zappa
deployment upgrades. This is with the latest zappa and django versions.
I had no issues when using the latest Flask (with latest zappa), FWIW.
For what it's worth, the steps listed by @philipn are exactly what I followed (independently) to first encounter this error. I then thought I must be doing something wrong, so I tried deploying the narfman0/zappa-examples example Django app, with the same results (see #703).
I did some digging, and I found the regression, from 6 days ago:
Reverting this hunk fixes the bug. The condition
if not hasattr(self.settings, 'APP_MODULE'):
evaluates to True
when using Django when it shouldn't.
I'd make a pull request but I'm not sure what @Miserlou was trying to do with this conditional. I'll leave it to him or somebody else more knowledgeable than I to handle the fix.
Pushed Hotfix @flux627
@Miserlou This error seems to be happening again. I am new to Zappa, so It could be that I'm just not doing it right, but I have followed the same steps as were originally reported and get the same error.
@tiamot i used to run into this all the time. it's probably because you don't have the handler.py file in your zip file deployed to the lambda. do a zappa package
I need more info than this. If it's a regression, please say which version broke, and post your settings, pip freeze, etc. In fact, make a new ticket and follow the issue template.
Ok, I posted my version of zappa and Django and os on slack as well. I’ll get started creating a ticket.
Basically I’m using the latest version of python3 Django and Zappa.
@BradNation4Eva I'll check it out
@BradNation4Eva , It looks like I do have a handler.py, My deployment shouldn't be big, I'm basically doing what @philipn did back in March. I'm not even creating any models or anything yet, just the base dummy install.
I just created a new issue: https://github.com/Miserlou/Zappa/issues/1210
I have tried to use Zappa 2 times from 2 different Django apps to 2 different AWS accounts and I get the exact same result both times. The deployment seems to work and I get this
Then I click on the link and I get this .. which I have no clue how to fix... Also nothing goes into the s3 bucket. { "message": "An uncaught exception happened while servicing this request.", "traceback": [ "Traceback (most recent call last):\n", " File \"/var/task/handler.py\", line 395, in handler\n response = Response.from_app(self.wsgi_app, environ)\n", " File \"c:\users\winuser\appdata\local\temp\pip-build-k_tf7n\Werkzeug\werkzeug\wrappers.py\", line 865, in from_app\n", " File \"c:\users\winuser\appdata\local\temp\pip-build-k_tf7n\Werkzeug\werkzeug\test.py\", line 871, in run_wsgi_app\n", "TypeError: 'NoneType' object is not callable\n" ] }