开发者

Why are celery_taskmeta and other tables not being created when running a syncdb in django?

开发者 https://www.devze.com 2023-03-25 23:43 出处:网络
I\'m trying to setup celery and django, but the celery_taskmeta table is not being created. I\'ve followed numerous (Recent) tutorials, added djcelery and djkombu to my installed_apps. added the \'BR

I'm trying to setup celery and django, but the celery_taskmeta table is not being created.

I've followed numerous (Recent) tutorials, added djcelery and djkombu to my installed_apps. added the 'BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"' line to my settings, etc.

I can run the daemon just fine, and it will execute tasks, but it spits out this traceback at the end:

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

 2011-08-05 16:21:16,231: ERROR/MainProcess] Task  slate.modules.filebrowser.tasks.gen_thumb_task[0afc564b-cc54开发者_如何学Go-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

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

so how the hell do i get this table created during syncdb?


The problem here is actually that South manages the djcelery tables. You need to migrate djcelery to it's new schema. If you upgraded djcelery from an earlier version and you already have a set of tables installed, you need to do a fake migration first:

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

I had the same problems before but this fixed it.


I was also getting the following error:

DatabaseError: no such table: djkombu_queue

After looking into it a bit further I believe the correct way to solve this problem (pulled from here) it to add the following to INSTALLED_APPS:

INSTALLED_APPS = ('djcelery.transport', )

Adding kombu.transport.django felt incorrect.


Ran into the exact same issue, fresh install. Downgrading celery and django-celery to 2.2.7 and rerunning syncdb solved it (for the interim, anyway).


I was getting a similar error:

DatabaseError: no such table: djkombu_queue

In my case, I needed to add a Django app from a related technology to the INSTALLED_APPS setting. In my case, it was: kombu.transport.django

After that, I reran syncdb and everything was working. In your case, maybe add something in the celery egg to the path.


I got this error while running manage.py dumpdata. I tried two different 2.2.x versions of the celery and django-celery packages with a MySQL database. In my case upgrading to 2.2.7 didn't fix the issue. What did work was advice found on this Github Issue #34.

When using dumpdata on Django 1.3+, add the --exclude djcelery option. (Of course, if you are dumping only a subset of apps and models you won't get the missing table error anyway. And if you aren't using dumpdata in the first place, this answer doesn't apply.)


The problem is probably SQLite3. You can not use it concurrently in Django and it is throwing an misleading error. Switch to PostgreSQL or MySQL, especially for celeryd development.

Or, bite the bullet, and setup RabbitMQ ...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号