简体   繁体   English

“模块”对象没有属性“芹菜”

[英]'module' object has no attribute 'celery'

I've been reading through the answers to some previous questions as well as the celery docs and I just can't quite fix this issue. 我一直在阅读一些以前的问题的答案以及celery文档,但我还不能完全解决此问题。 My task.py, celery.py, and settings.py are all contained within the same app RBWebfiles which is contained within the project called recruiting board. 我的task.py,celery.py和settings.py都包含在同一个应用程序RBWebfiles中,该应用程序包含在称为募集板的项目中。 I'm attempting to creating a periodic-task that will run using celery beat's scheduler. 我正在尝试创建一个将使用celery beat的调度程序运行的定期任务。

This is the portion of my settings.py that deals with celery: 这是我的settings.py中涉及芹菜的部分:

from __future__ import absolute_import
import os
from datetime import timedelta


CELERY_IMPORTS = ('RBWebfiles.tasks')

CELERYBEAT_SCHEDULE = 'djcelery.schedulers.DatabaseScheduler'
CELERYBEAT_SCHEDULE = {
    'schedule-name':{
        'task': 'RBWebfiles.tasks.requestRefresher',
        'schedule': timedelta(seconds = 30),
    },
}

BROKER_URL = 'django://'

I also added 'djcelery' to my installed apps within that file 我还在该文件中的已安装应用程序中添加了“ djcelery”

This is my tasks.py file: 这是我的task.py文件:

from __future__ import absolute_import
import datetime
from celery.task.base import periodic_task
from student.models import StudentAccount
from celery import Celery
from celery.utils.log import get_task_logger
import os

celery = Celery('tasks', broker='django://')
logger = get_task_logger(__name__)


os.environ['DJANGO_SETTINGS_MODULE'] = 'RBWebfiles.settings'


@periodic_task(run_every=datetime.timedelta(seconds=30))
def requestRefresher(self):
    logger.info("start task")
    for s in StudentAccount.objects.all():
        s.requestLimit = 0
        s.save()
    return None

and lastly this is my celery.py file: 最后这是我的celery.py文件:

from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conf.settings')
app = Celery('RBWebfiles.celery')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda : settings.INSTALLED_APPS)

app.conf.update(
    CELERY_RESULT_BACKEND ='djcelery.backends.database:DatabaseBackend',
)

@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))

I've tried uninstalling and reinstalling both celery and django-celery, I'm not sure if I just don't understand something or I'm making a massive error. 我尝试卸载并重新安装celery和django-celery,但不确定是否只是不了解某些内容,或者正在犯大量错误。 I attempt to run it using the command : celery beat -A RBWebfiles 我尝试使用以下命令运行它:celery beat -A RBWebfiles

this is the traceback: 这是回溯:

C:\Users\Lexie Infantino\PycharmProjects\recruitingboard>celery beat -A   RBWebfiles
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\celery\app\utils.py", line 235, in     find_app
    found = sym.app
AttributeError: 'module' object has no attribute 'app'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python34\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python34\Scripts\celery.exe\__main__.py", line 9, in <module>
  File "C:\Python34\lib\site-packages\celery\__main__.py", line 30, in main
    main()
  File "C:\Python34\lib\site-packages\celery\bin\celery.py", line 81, in     main
    cmd.execute_from_commandline(argv)
  File "C:\Python34\lib\site-packages\celery\bin\celery.py", line 769, in     execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "C:\Python34\lib\site-packages\celery\bin\base.py", line 309, in     execute_from_commandline
   argv = self.setup_app_from_commandline(argv)
  File "C:\Python34\lib\site-packages\celery\bin\base.py", line 469, in     setup_app_from_commandline
    self.app = self.find_app(app)
  File "C:\Python34\lib\site-packages\celery\bin\base.py", line 489, in     find_app
    return find_app(app, symbol_by_name=self.symbol_by_name)
  File "C:\Python34\lib\site-packages\celery\app\utils.py", line 240, in     find_app
    found = sym.celery
AttributeError: 'module' object has no attribute 'celery'

确保djcelery在您的INSTALLED_APPS中,然后尝试使用manage.py celerybeat来启动celery beat。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Celery,AttributeError:“模块”对象没有属性“ celeryconfig” - Celery, AttributeError: 'module' object has no attribute 'celeryconfig' AttributeError:&#39;module&#39;对象没有属性&#39;celery&#39; - AttributeError: 'module' object has no attribute 'celery' 启动Celery:AttributeError:&#39;module&#39;对象没有属性&#39;celery&#39; - Starting Celery: AttributeError: 'module' object has no attribute 'celery' 模块“module”没有属性“celery” - Module 'module' has no attribute 'celery' 使用 Python 3 时,Celery &#39;module&#39; 对象没有属性 &#39;app&#39; - Celery 'module' object has no attribute 'app' when using Python 3 模块“project_name”没有属性“celery” - Module 'project_name' has no attribute 'celery' Django / Celery-AttributeError:模块&#39;novopagemento&#39;没有属性&#39;celery&#39; - Django/Celery - AttributeError: module 'novopagemento' has no attribute 'celery' Celery 工作人员未启动:“模块‘proj’没有属性‘celery’” - Celery worker not starting: "Module 'proj' has no attribute 'celery'" Celery - AttributeError:&#39;NoneType&#39;对象没有属性&#39;delay&#39; - Celery - AttributeError: 'NoneType' object has no attribute 'delay' 如何解决此 celery 错误:无法加载 celery 应用程序。 模块“预测”没有属性“芹菜” - How to solve this celery Error: Unable to load celery application. Module 'forecast' has no attribute 'celery'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM