标签:span check return add print backend config 文件 pass
老是整忘记,记录一下rabbitmq使用过程
1、No module named ‘celery.backends.amqp‘ or KeyError: ‘backend‘ #6384
import subprocess from time import sleep import config from celery import Celery url = "amqp://%s:%s@%s:5672/%s" % (config.rabbitmq_user, config.rabbitmq_password, config.rabbitmq_host, config.rabbitmq_vhost) print(url) app = Celery(‘mq‘, backend=url, broker=url) @app.task def add(x, y): sleep(10) return x + y @app.task def hostname(): return subprocess.check_output([‘hostname‘])
3、消费启动者
celery -A mq worker --loglevel=info # 在消费代码文件夹下执行上面命令,mq是关键代码的名字
标签:span check return add print backend config 文件 pass
原文地址:https://www.cnblogs.com/xugongzi007/p/14309386.html