Celery 未提供主机名。恢复默认“本地主机”

Pro*_*eno 11 django celery

我的里面有这个/var/log/celery/w1.log

在此输入图像描述

我正在按照此处的Celery 步骤进行操作。

我的里面有这个celery.py

from __future__ import absolute_import, unicode_literals

import os

from celery import Celery

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sample.settings')

app = Celery('sample2',
            broker='amqp://',
            include=['sample2.tasks'])

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix. 
app.config_from_object('django.conf:settings', namespace='CELERY')

if __name__ == '__main__':
    app.start()
Run Code Online (Sandbox Code Playgroud)

我能做什么来解决这个问题?提前致谢。

roo*_*eki 6

完整文档在此链接中。

您应该将以下行添加到__init__.pysettings.py 附近

from .celery import app as celery_app

__all__ = ['celery_app']
Run Code Online (Sandbox Code Playgroud)

项目结构

- proj/
  - manage.py
  - proj/
    - __init__.py
    - settings.py
    - urls.py
Run Code Online (Sandbox Code Playgroud)