Django-celery 弃用错误?

发布于 2024-12-17 15:01:25 字数 641 浏览 5 评论 0原文

我刚刚启动 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()

我找不到此错误的任何文档。这是怎么回事?

I just started up django-celery and got this warning:

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.

Here's my test task:

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

I'm calling it from a view with:

myProcessingFunction.delay()

I can't find any documentation for this error. What's going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情丝乱 2024-12-24 15:01:25

它告诉您,您正在使用的装饰器 (task()) 将从 celery 的后续版本中删除,因此您应该考虑将其从代码中删除:

celery.task.task应该使用而不是celery.decorators.task`

所以

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

It's telling you that the decorator you are using (task()) is going to be taken out of subsequent versions of celery so you should look to remove it from your code:

celery.task.taskshould be used instead ofcelery.decorators.task`

so

from celery.task import task # instead of celery.decorators
@task()
def myProcessingFunction():
    print "Zing!"
    return 1
没企图 2024-12-24 15:01:25

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

from celery.task import task 

from celery import task 

According to http://docs.celeryproject.org/en/latest/internals/deprecation.html#old-task-api it sounds like you should also now change

from celery.task import task 

to

from celery import task 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文