1

我在 Django Admin 中找不到任何任务状态。

所有 5 张桌子都毫无希望地空着:

  • crontabs
  • 间隔
  • 定期任务
  • 任务
  • 工作人员

这是我的settings.py:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'djcelery',
    #...
)

BROKER_TRANSPORT = "mongodb"
BROKER_URL = "mongodb://xxx:yyy@zzz"
CELERY_RESULT_BACKEND = "database"

import djcelery
djcelery.setup_loader()

这是我的tasks.py:

from celery import task

@task()
def add(x, y):
    return x + y

现在,当我想尝试它时:

python manage.py celery worker --loglevel=info &
python manage.py shell
>>> from apps.me_core import tasks
>>> tasks.add.delay(2,3)

[2013-07-07 11:06:12,274: INFO/MainProcess] Got task from broker: apps.me_core.tasks.add[9e5bbf1b-a0df-4fa4-851e-281dc79df866]
[2013-07-07 11:06:12,310: INFO/MainProcess] Task apps.me_core.tasks.add[9e5bbf1b-a0df-4fa4-851e-281dc79df866] succeeded in 0.0213570594788s: 5

编辑

我已经能够通过python manage.py shell.

>>> from djcelery.models import TaskMeta
>>> TaskMeta.objects.count()
51
>>> TaskMeta.objects.db
'default'
>>> TaskMeta.objects.current_engine()
'django.contrib.gis.db.backends.postgis'
>>> conn = TaskMeta.objects.connection_for_write()
>>> conn.connection
<connection object at 0x7fca897659b0; dsn: 'dbname=mydbname user=postgres password=xxxxxxxx host=localhost', closed: 0>

它们存储在哪里?我无法使用 pgAdmin3 或 Django admin 找到它们!这真让我抓狂...

4

1 回答 1

0

我要找的桌子是celery_taskmeta.

这是一张celery桌子,不是django-celery一张。

于 2013-07-07T12:11:28.697 回答