我是异步和芹菜新手,这是我第一次。而且我对任务有疑问。我的任务只是将带有字段的对象作为对象,并从IntegerField中减去一。当我从python manage.py shell使用此方法时,此方法有效。但是,当我要在芹菜任务中执行此操作时,此操作无效。我也不知道发生了什么,只是对我说了什么。.有人可以告诉我我怎么得到为什么我打电话时没有输出的原因
芹菜工人-一个项目名
REDIS_HOST = 'localhost'
REDIS_PORT = '6379'
BROKER_URL = 'redis://' + REDIS_HOST + ':' + REDIS_PORT + '/0'
BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 3600}
CELERY_RESULT_BACKEND = 'redis://' + REDIS_HOST + ':' + REDIS_PORT + '/0'
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings')
app = Celery('project_name')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks()
from project_name.celery import app
from .models import Post
@app.task
def check_post():
posts = Post.objects.filter(premium=True)
if salons.count() > 0:
for post in posts:
salon.minus_premium_day()
return True
else:
return False
---- **** -----
--- * *** * -- Linux-4.9.132-0-beget-acl-x86_64-with-debian-wheezy-sid 2019-01-27 01:41:51
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: project_name:0x7f4e595081d0
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis://localhost:6379/0
- *** --- * --- .> concurrency: 12 (prefork)
-- ******* ---- .> task events: ON
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery