Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django-celery deprecation error?

Tags:

django

celery

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?

like image 303
Abe Avatar asked Feb 23 '23 07:02

Abe


2 Answers

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
like image 156
Timmy O'Mahony Avatar answered Mar 07 '23 04:03

Timmy O'Mahony


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 
like image 45
Mark Chackerian Avatar answered Mar 07 '23 03:03

Mark Chackerian