Django-celery弃用错误?

时间:2011-11-23 21:51:05

标签: django celery

我刚启动了django-celery并得到了这个警告:

DeprecationWarning: 
The `celery.decorators` module and the magic keyword arguments
are pending deprecation and will be deprecated in 2.4, then removed
in 3.0.

`task.request` should be used instead of magic keyword arguments,
and `celery.task.task` used instead of `celery.decorators.task`.

See the 2.2 Changelog for more information.

这是我的测试任务:

from celery.decorators import task
@task()
def myProcessingFunction():
  print "Zing!"
  return 1

我从以下视图中调用它:

myProcessingFunction.delay()

我找不到此错误的任何文档。发生了什么事?

2 个答案:

答案 0 :(得分:7)

它告诉你你正在使用的装饰器(task())将从后续版本的celery中取出,所以你应该从你的代码中删除它:

  

celery.task.task should be used instead of celery.decorators.task`

所以

from celery.task import task # instead of celery.decorators
@task()
def myProcessingFunction():
    print "Zing!"
    return 1

答案 1 :(得分:0)

根据http://docs.celeryproject.org/en/latest/internals/deprecation.html#old-task-api,听起来你现在也应该改变

from celery.task import task 

from celery import task