10

我正在尝试设置 celery 和 django,但没有创建 celery_taskmeta 表。

我遵循了许多(最近的)教程,将 djcelery 和 djkombu 添加到了我的 installed_apps。将 'BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"' 行添加到我的设置等中。

我可以很好地运行守护进程,它会执行任务,但最后会吐出这个回溯:

===============

 2011-08-05 16:21:16,231: ERROR/MainProcess] Task  slate.modules.filebrowser.tasks.gen_thumb_task[0afc564b-cc54-4f4c-83f5-6db56fb23b76] raised exception: DatabaseError('no such table: celery_taskmeta',)
 Traceback (most recent call last):
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/worker/job.py", line 107, in execute_safe
    return self.execute(*args, **kwargs)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/worker/job.py", line 125, in execute
    return super(WorkerTaskTrace, self).execute()
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/execute/trace.py", line 79, in execute
    retval = self._trace()
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/execute/trace.py", line 93, in _trace
    r = handler(trace.retval, trace.exc_type, trace.tb, trace.strtb)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/worker/job.py", line 140, in handle_success
    self.task.backend.mark_as_done(self.task_id, retval)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/backends/base.py", line 54, in mark_as_done
    return self.store_result(task_id, result, status=states.SUCCESS)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/celery/backends/base.py", line 194, in store_result
    return self._store_result(task_id, result, status, traceback, **kwargs)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/djcelery/backends/database.py", line 20, in _store_result
    traceback=traceback)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/djcelery/managers.py", line 36, in _inner
    return fun(*args, **kwargs)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/djcelery/managers.py", line 154, in store_result
    "traceback": traceback})
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/djcelery/managers.py", line 78, in update_or_create
    return self.get_query_set().update_or_create(**kwargs)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/djcelery/managers.py", line 62, in update_or_create
    obj, created = self.get_or_create(**kwargs)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/query.py", line 378, in get_or_create
    return self.get(**lookup), False
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/query.py", line 344, in get
    num = len(clone)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/query.py", line 82, in __len__
    self._result_cache = list(self.iterator())
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
    for row in compiler.results_iter():
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
    cursor.execute(sql, params)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site- packages/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/Users/erichutchinson/python-env/slate/lib/python2.7/site- packages/django/db/backends/sqlite3/base.py", line 234, in execute
    return Database.Cursor.execute(self, query, params)
 DatabaseError: no such table: celery_taskmeta

-=============================

那么我到底是如何在syncdb期间创建这个表的呢?

4

6 回答 6

18

这里的问题实际上是 South 管理 djcelery 表。您需要将 djcelery 迁移到它的新模式。如果您从早期版本升级 djcelery 并且已经安装了一组表,则需要先进行假迁移:

python manage.py migrate djcelery 0001 --fake
python manage.py migrate djcelery

我之前遇到过同样的问题,但这解决了它。

于 2012-03-29T03:02:54.757 回答
10

我也收到以下错误:

DatabaseError: no such table: djkombu_queue

在进一步研究之后,我相信解决这个问题的正确方法(从这里拉出来)它将以下内容添加到INSTALLED_APPS

INSTALLED_APPS = ('djcelery.transport', )

添加kombu.transport.django感觉不正确。

于 2012-08-28T19:30:26.507 回答
5

遇到完全相同的问题,全新安装。将 celery 和 django-celery 降级到 2.2.7 并重新运行 syncdb 解决了它(无论如何都是临时的)。

于 2011-08-08T04:49:11.180 回答
5

我遇到了类似的错误:

DatabaseError: no such table: djkombu_queue

就我而言,我需要将一个来自相关技术的 Django 应用程序添加到INSTALLED_APPS设置中。就我而言,它是:kombu.transport.django

之后,我重新运行syncdb,一切正常。在您的情况下,也许在芹菜蛋中添加一些东西到路径中。

于 2012-02-10T02:47:28.403 回答
1

运行时出现此错误manage.py dumpdata。我用 MySQL 数据库尝试了两个不同的 2.2.x 版本的celerydjango-celery包。就我而言,升级到 2.2.7 并没有解决问题。起作用的是在这个 Github问题 #34上找到的建议。

在 Django 1.3+ 上使用 dumpdata 时,添加--exclude djcelery选项。(当然,如果您只转储应用程序和模型的子集,则无论如何都不会出现丢失表错误。如果您一开始没有使用转储数据,则此答案不适用。)

于 2012-02-01T02:10:36.693 回答
0

问题可能是 SQLite3。您不能在 Django 中同时使用它,它会引发误导性错误。切换到 PostgreSQL 或 MySQL,尤其是用于 celeryd 开发。

或者,咬紧牙关,设置 RabbitMQ ...

于 2011-08-05T20:30:48.557 回答