redis
http://debugo.com/python-redis
celery
https://gist.github.com/neara/11214948
https://gist.github.com/amatellanes/a986f6babb9cf8556e36
https://gist.github.com/IrSent/5e4820f6b187d3654967b55e27d5d204
http://funhacks.net/2016/12/13/celery/
https://www.ibm.com/developerworks/cn/opensource/os-cn-celery-web-service/index.html
http://docs.jinkan.org/docs/celery/getting-started/introduction.html
http://liuzxc.github.io/blog/celery/
https://realpython.com/blog/python/flask-by-example-implementing-a-redis-task-queue
http://liuzxc.github.io/blog/celery
http://blog.wifibao.im/index.php/archives/166
http://www.jianshu.com/p/1840035cb510
http://www.jianshu.com/p/9e422d9f1ce2
flask & celery:
https://blog.miguelgrinberg.com/post/using-celery-with-flask
http://liyangliang.me/posts/2015/11/using-celery-with-flask
http://shulhi.com/celery-integration-with-flask
http://aviaryan.in/blog/gsoc/celery-flask-using.html
http://doc.scalingo.com/languages/python/celery/getting-started-with-celery-and-flask
http://www.adikrishnan.in/2016/03/03/using-celery-with-flask/
flask & celery & redis:
http://celeodor.com/flask-flask-socketio-celery-and-redis-background-task-processing
https://moinulhossain.me/remote-celery-worker-for-flask-with-separate-code-base
http://louistiao.me/posts/deploy-flask-with-a-celery-task-queue-and-flower-dashboard-using-kubernetes
http://www.cnblogs.com/ajianbeyourself/p/4471391.html
ansible & celery
http://fengxsong.github.io/2016/05/27/ansible-celery
https://github.com/Erazx/ansible_api
https://github.com/onlytiancai/ansible-celery-flask-demo
https://github.com/yumaojun03/ansible_async_api
https://github.com/fengxsong/django-example
http://www.cnblogs.com/piperck/p/5391128.html
http://www.revsys.com/12days
yum -y install redis
chkconfig redis on && /etc/init.d/redis start
venv
pip install redis -i https://pypi.douban.com/simple
pip install celery -i https://pypi.douban.com/simple
broker(broker.py)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from celery import Celery, platforms
platforms.C_FORCE_ROOT = True
app = Celery(__name__, broker='redis://127.0.0.1:6379/0', backend='redis://127.0.0.1:6379/0', include=['tasks'])
worker(tasks.py)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from broker import app
import time
@app.task
def longtime_add(x, y):
print 'long time task begins'
# sleep 5 seconds
time.sleep(5)
print 'long time task finished'
return x + y
client(run_tasks.py)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tasks import longtime_add
import time
if __name__ == '__main__':
result = longtime_add.delay(1,2)
# at this time, our task is not finished, so it will return False
print 'Task finished? ', result.ready()
print 'Task result: ', result.result
# sleep 10 seconds to ensure the task has been finished
time.sleep(10)
# now the task should be finished and ready method will return True
print 'Task finished? ', result.ready()
print 'Task result: ', result.result
celery -A broker worker -l info
python run_tasks.py