@tony-yin
2018-04-03T09:23:46.000000Z
字数 572
阅读 1132
Celery
yum install erlang
yum install rabbitmq-server -y
systemctl start rabbitmq-server
systemctl enable rabbitmq-server
yum repolist
yum install redis php-pecl-redis
systemctl start redis
systemctl enable redis
pip install redis
from tasks import add
add.delay(5, 5)
with open('output.log', 'a') as f:
f.write('===== current ====' + "\n")
from celery import Celery
app = Celery('tasks', broker='redis://guest@localhost//')
@app.task
def add(x, y):
with open('output.log', 'a') as f:
f.write('===== delay ====' + "\n")
return x + y
server:
celery -A tasks worker --loglevel=info
client:
python client.py