1.celery配置与基本使用
1.1 安装celery
pip install celery @ https://github.com/celery/celery/tarball/master
1.2 新建celery/main.py配置celery
import os
from celery import Celery
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
转载请注明原文地址:https://blackberry.8miu.com/read-33746.html