python - django/celery - celery 状态 : Error: No nodes replied within time constraint

标签 python django celery django-celery

我正在尝试在我的生产服务器中部署一个简单的 celery 示例,我已经按照 celery 网站上关于将 celery 作为守护进程运行的教程进行操作 http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#daemonizing ,我在 /etc/default/celeryd

中得到了配置文件
  1 # Name of nodes to start
  2 # here we have a single node
  3 CELERYD_NODES="w1"
  4 # or we could have three nodes:
  5 #CELERYD_NODES="w1 w2 w3"
  6 
  7 # Where to chdir at start.
  8 CELERYD_CHDIR="/home/audiwime/cidec_sw"
  9 
 10 # Python interpreter from environment.
 11 ENV_PYTHON="/usr/bin/python26"
 12 
 13 # How to call "manage.py celeryd_multi"
 14 CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi"
 15 
 16 # # How to call "manage.py celeryctl"
 17 CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl"
 18 
 19 # Extra arguments to celeryd
 20 CELERYD_OPTS="--time-limit=300 --concurrency=8"
 21 
 22 # Name of the celery config module.
 23 CELERY_CONFIG_MODULE="celeryconfig"
 24 
 25 # %n will be replaced with the nodename.
 26 CELERYD_LOG_FILE="/var/log/celery/%n.log"
 27 CELERYD_PID_FILE="/var/run/celery/%n.pid"
 28 
 29 # Workers should run as an unprivileged user.
 30 CELERYD_USER="audiwime"
 31 CELERYD_GROUP="audiwime"
 32 
 33 export DJANGO_SETTINGS_MODULE="cidec_sw.settings"

but if I run

celery status

in the terminal, i got this response:

Error: No nodes replied within time constraint

I can restart celery via the celeryd script provided in https://github.com/celery/celery/tree/3.0/extra/generic-init.d/

/etc/init.d/celeryd restart
celeryd-multi v3.0.12 (Chiastic Slide)
> w1.one.cloudwime.com: DOWN
> Restarting node w1.one.cloudwime.com: OK

I can run python26 manage.py celeryd -l info and my tasks in django run fine, but if I let the daemon do its work I don't get any results, don't even errors in /var/log/celery/w1.log

I know that my task has been registered because I did this

from celery import current_app
def call_celery_delay(request):
    print current_app.tasks
    run.delay(request.GET['age'])
    return HttpResponse(content="celery task set",content_type="text/html")

然后我得到一本字典,其中出现了我的任务

{'celery.chain': <@task: celery.chain>, 'celery.chunks': <@task: celery.chunks>, 'celery.chord': <@task: celery.chord>, 'tasks.add2': <@task: tasks.add2>, 'celery.chord_unlock': <@task: celery.chord_unlock>, **'tareas.tasks.run': <@task: tareas.tasks.run>**, 'tareas.tasks.add': <@task: tareas.tasks.add>, 'tareas.tasks.test_two_minute': <@task: tareas.tasks.test_two_minute>, 'celery.backend_cleanup': <@task: celery.backend_cleanup>, 'celery.map': <@task: celery.map>, 'celery.group': <@task: celery.group>, 'tareas.tasks.test_one_minute': <@task: tareas.tasks.test_one_minute>, 'celery.starmap': <@task: celery.starmap>}

但除此之外我什么也得不到,我的任务没有结果,日志中没有错误,什么都没有。 有什么问题吗?

最佳答案

使用以下命令查找问题:

C_FAKEFORK=1 sh -x /etc/init.d/celeryd start

这通常是因为您的源项目中存在问题(权限问题、语法错误等)

如 celery 文档中所述:-

If the worker starts with “OK” but exits almost immediately afterwards and there is nothing in the log file, then there is probably an error but as the daemons standard outputs are already closed you’ll not be able to see them anywhere. For this situation you can use the C_FAKEFORK environment variable to skip the daemonization step

祝你好运

来源:Celery Docs

关于python - django/celery - celery 状态 : Error: No nodes replied within time constraint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13575711/

相关文章:

python - 由于 python.config 中的 YAML 错误,部署到 AWS EB 失败

python - model.save 上的 Django Filefield UnicodeDecodeError

django - 在 Heroku 上运行的 Celery Beat 进程发送任务两次

Python:更改 Windows 时区后时间戳不正确

python - 如何在 Django 中创建自定义管理配置面板?

django - django 模型是否提供类似于表单的 clean_<fieldname>() 的东西?

python - Docker 中的 Celery kombu.exceptions.ContentDisallowed

Python Celery 可以从进程内线程开始吗?

python - 如何避免 tkinter GUI 卡住?

python - 如何根据 'groupby' 和 'mean' 函数绘制直方图