芹菜在get_scheduler上击败TypeError



试图设置运行 Python3.5Django==1.10.2celery==4.0.2的芹菜,但正在使用主管,但在site-packages/celery/beat

上遇到此错误
Traceback (most recent call last):
  File "/home/user_one/venv/app_one/bin/celery", line 11, in <module>
    sys.exit(main())
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/__main__.py", line 14, in main
    _main()
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/celery.py", line 326, in main
    cmd.execute_from_commandline(argv)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/celery.py", line 488, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/base.py", line 281, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/celery.py", line 480, in handle_argv
    return self.execute(command, argv)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/celery.py", line 412, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/base.py", line 285, in run_from_argv
    sys.argv if argv is None else argv, command)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/base.py", line 368, in handle_argv
    return self(*args, **options)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/base.py", line 244, in __call__
    ret = self.run(*args, **kwargs)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/bin/beat.py", line 107, in run
    return beat().run()
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/apps/beat.py", line 79, in run
    self.start_scheduler()
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/apps/beat.py", line 98, in start_scheduler
    print(self.banner(service))
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/apps/beat.py", line 120, in banner
    c.reset(self.startup_info(service))),
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/apps/beat.py", line 130, in startup_info
    scheduler = service.get_scheduler(lazy=True)
  File "/home/user_one/venv/app_one/lib/python3.5/site-packages/celery/beat.py", line 567, in get_scheduler
    lazy=lazy,
TypeError: 'module' object is not callable

app/settings.py

BROKER_URL = 'redis://:{}@{}:{}/{}'.format(redis_pass, redis_host, redis_port, redis_db)
CELERY_RESULT_BACKEND = 'redis://:{}@{}:{}/{}'.format(redis_pass, redis_host, redis_port, redis_celery_results_db)
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

app/celery.py

from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app_one.settings')
cel_app = Celery('app_one')
cel_app.config_from_object('django.conf:settings')
cel_app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@cel_app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))

我以前在其他项目中成功使用过芹菜,但与Django没有。我遵循此处指定的设置。我可以错过什么吗?

所有邪恶的根都在主管配置文件中,即/etc/supervisor/conf.d/celer_beat.conf.conf

command=/home/user_one/venv/app_one/bin/celery -A app_one beat --loglevel=INFO -S django

-S django是指我不使用的django_celery_beat。因此,然后将其更改为:

command=/home/user_one/venv/app_one/bin/celery -A app_one beat -s /home/user_one/apps/app_one/celerybeat-schedule --loglevel=INFO

这样,芹菜在应用程序目录中使用文件(即/home/user_one/apps/app_one/目录。

(跟踪时间表。

相关内容

  • 没有找到相关文章

最新更新