我有一个芹菜的helloworld类型函数:
from celery import Celery
import time
app = Celery('test_celery',
broker= 'amqp://celeryuser:pass@ip:5672/celeryvhost',
)
@app.task
def add(x, y):
time.sleep(2)
print('calculating something aaewsome --------------------')
return x + y
if __name__ == '__main__':
result = add.delay(4, 4)
print( result.get() )
我运行命令来运行任务:
celery -A test_celery worker --loglevel=info
我得到输出:
[tasks]
. test_celery.add
[2018-07-17 00:17:40,668: INFO/MainProcess] Connected to amqp://celeryuser:**@myip:5672/celeryvhost
[2018-07-17 00:17:40,679: INFO/MainProcess] mingle: searching for neighbors
[2018-07-17 00:17:41,705: INFO/MainProcess] mingle: sync with 1 nodes
[2018-07-17 00:17:41,706: INFO/MainProcess] mingle: sync complete
[2018-07-17 00:17:41,725: INFO/MainProcess] celery@www.mysite.com ready.
在日志中显示:
[2018-07-17 00:17:40,698: INFO/MainProcess] sync with celery@mysite.com
但是没有输出打印。
我在做什么错了?