<p><em>(转换为注释中的答案)</em></p>
<p>从<a href="http://pastebin.com/Qgcr6EDB" rel="nofollow">stack trace</a>中,我认为<code>return backend(app=self, url=url)</code>行是发生异常的地方。</p>
<p>所以不管<code>backend</code>是什么,它似乎都不是可调用的。我将尝试在该文件(<code>celery/app/base.py</code>)中设置pdb断点,方法是将该行包装为</p>
<pre><code>try:
backend(app=self, url=url)
except:
import pdb; pdb.set_trace(),
</code></pre>
<p>然后检查<code>backend</code>,向上移动堆栈(pdb中的<code>u</code>命令,<code>d</code>再次向下移动,<code>w</code>显示调用堆栈)以调试出错的地方。</p>
<p><a href="http://docs.celeryproject.org/en/latest/userguide/tasks.html#basics" rel="nofollow">celery docs</a>也提到了这一点:</p>
<blockquote>
<p><strong>How do I import the task decorator?</strong></p>
<p>The task decorator is available on your Celery instance, if you don’t know what that is then please read First Steps with Celery.</p>
<p><strong>If you’re using Django or are still using the “old” module based celery API</strong>, then you can import the task decorator like this:</p>
</blockquote>
<pre><code>from celery import task
@task
def add(x, y):
return x + y
</code></pre>
<p>因此,这应该可以澄清关于导入任务decorator的正确方法的任何含糊不清之处。</p>