Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was able to reproduce your issue:</p> <pre><code>import celery from celery.task import Task @celery.task class Foo(celery.Task): name = "foo" def run(self, batch): print 'Foo' class Bar(celery.Task): name = "bar" def run(self, batch): print 'Bar' # subclass deprecated base Task class class Bar2(Task): name = "bar2" def run(self, batch): print 'Bar2' @celery.task(name='def-foo') def foo(batch): print 'foo' </code></pre> <p>Output:</p> <pre><code>In [2]: foo.delay('x') [WARNING/PoolWorker-4] foo In [3]: Foo().delay('x') [WARNING/PoolWorker-2] Foo In [4]: Bar().delay('x') [WARNING/PoolWorker-3] Bar In [5]: Foo.delay('x') TypeError: object.__new__() takes no parameters In [6]: Bar.delay('x') TypeError: unbound method delay() must be called with Bar instance as first argument (got str instance instead) In [7]: Bar2.delay('x') [WARNING/PoolWorker-1] Bar2 </code></pre> <p>I see you use deprecated <code>celery.task.Task</code> base class, this is why you don't get <code>unbound method</code> errors:</p> <pre><code>Definition: Task(self, *args, **kwargs) Docstring: Deprecated Task base class. Modern applications should use :class:`celery.Task` instead. </code></pre> <p>I don't know why <code>ProcessRequests</code> doesn't work though. Maybe it is some caching issues, you may have tried to apply the decorator to your class before and it got cached, and this is exactly the error that you get when you try to apply this decorator to a Task class.</p> <p>Delete all .pyc file, restart celery workers and try again.</p> <p><strong>Don't use classes directly</strong></p> <ol> <li><a href="http://docs.celeryproject.org/en/latest/userguide/tasks.html#instantiation" rel="nofollow">Tasks are instantiated only once per (worker) process</a>, so creating objects of task classes (on client-side) every time doesn't make sense, i.e. <code>Bar()</code> is wrong.</li> <li><code>Foo.delay()</code> or <code>Foo().delay()</code> might or might not work, depends on combination of decorator <code>name</code> argument and class <code>name</code> attribute.</li> </ol> <p>Get the task object from <code>celery.registry.tasks</code> dictionary or just use <code>@celery.task</code> decorator on functions (<code>foo</code> in my example) instead.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload