Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Last active August 29, 2015 13:55
Show Gist options
  • Save toritori0318/8714862 to your computer and use it in GitHub Desktop.
Save toritori0318/8714862 to your computer and use it in GitHub Desktop.
boto 2.24.0 (gevent?) problem...
# -*- coding: utf-8 -*-
from flask import Flask
app = Flask(__name__)
app.config['DEBUG'] = True
import boto.sqs
AWS_ACCESS_KEY = 'xxxxxxxxxxxxxx'
AWS_SECRET_KEY = 'xxxxxxxxxxxxxx'
class SqsClient(object):
def __init__(self, queue_name):
self.conn = boto.sqs.connect_to_region(
"ap-northeast-1",
aws_access_key_id=AWS_ACCESS_KEY,
aws_secret_access_key=AWS_SECRET_KEY)
# blocking?????
self.queue = self.conn.get_queue(queue_name)
#
sqs_post = SqsClient('testtest')
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
# yum / python / python-packages setup
curl https://gist.github.com/toritori0318/8714862/raw/f0da601132e6e563bc0bb4616df4fc3fbbc8ae43/setup.sh | sh -
# flask app
curl -L -o hello.py https://gist.github.com/toritori0318/8714862/raw/b6dec8cdf2f03bd09e5a4e468e9896bf3b3cb71d/hello.py
# edit access_key and secret_key ...
vi hello.py
# boot app(no problem)
gunicorn hello:app
# boot app(no response..)
# [ERROR] gunicorn.error: WORKER TIMEOUT (pid:23475)
gunicorn -k gevent hello:app
# packages
sudo yum -y groupinstall "Development Tools"
sudo yum -y install python27 python27-devel python27-tools
sudo yum -y install libevent libevent-devel
# easy_install
sudo curl -o /usr/local/src/ez_setup.py https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
cd /usr/local/src/
sudo /usr/bin/python27 ez_setup.py
# pip
sudo easy_install-2.7 pip
# boto
sudo pip install Flask gunicorn gevent boto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment