1.celery配置与基本使用
1.1 安装celery
pip install celery @ https://github.com/celery/celery/tarball/master
1.2 新建celery_task/main.py配置celery
import os
from celery
import Celery
定义celery实例
, 需要的参数
, 1, 实例名
, 2, 任务发布位置
, 3, 结果保存位置
app
= Celery
('mycelery',
broker
='redis://127.0.0.1:6379/14',
backend
='redis://127.0.0.1:6379/15')
@app
.task
def add(x
, y
):
return x
+ y
2.测试celery
2.1 启动celery
'''1.启动celery'''
celery
-A main worker
-l INFO
celery multi start celery_test
-A celery_test
-l debug
--autoscale
=50,5
ps auxww
|grep
"celery worker"|grep
-v grep
|awk
'{print $2}'|xargs kill
-9