我想在方法任務上運行celerybeat,並且不能正確解決任何問題。下面是一個例子設置:芹菜擊敗與方法任務不工作
from celery.contrib.methods import task_method
from celery import Celery, current_app
celery=celery('tasks', broker='amqp://[email protected]//')
celery.config_from_object("celeryconfig")
class X(object):
@celery.task(filter=task_method, name="X.ppp")
def ppp(self):
print "ppp"
和我celeryconfig.py文件
from datetime import timedelta
CELERYBEAT_SCHEDULE = {
'test' : {
'task' : 'X.ppp',
'schedule' : timedelta(seconds=5)
},
}
當我運行celery beat
,我越來越像錯誤:
task X.ppp raised exception, TypeError('ppp() takes exactly 1 argument, (0 given)
當我打開方法到一個正常的函數中,並用`@ celery.task'來裝飾它,它確實起作用,所以其餘的設置似乎正在工作。我看到了一些注意事項in the docs about method tasks,但並不能真正理清問題所在。有誰知道如何解決這個問題?
嗨,你設法解決它使用類方法,而不是在python模塊中使用函數?我具有相同的確切情況,但是我的應用程序在類中被大量實現,所以我現在無法使其運行。您能幫助嗎? – securecurve
我從來沒有找到答案,但我一直沒有找到一個。如果你找到一個好的解決方案,讓我知道。 – reptilicus