【问题标题】:celery Bad magic number in docker芹菜 泊坞窗中的坏幻数
【发布时间】:2019-08-01 22:22:44
【问题描述】:

我可以使用终端中的命令正常运行 celery beat,但是当我使用 docker 运行时,出现以下错误:

[2019-03-11 11:46:27,327: INFO/MainProcess] beat: Starting...
celery_beat_taxithe | [2019-03-11 11:46:27,489: ERROR/MainProcess] Removing corrupted schedule file 'celerybeat-schedule': error('Bad magic number',)
celery_beat_taxithe | Traceback (most recent call last):
celery_beat_taxithe |   File "/usr/local/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in __get__
celery_beat_taxithe |     return obj.__dict__[self.__name__]
celery_beat_taxithe | KeyError: 'scheduler'
celery_beat_taxithe | 
celery_beat_taxithe | During handling of the above exception, another exception occurred:
celery_beat_taxithe | 
celery_beat_taxithe | Traceback (most recent call last):
celery_beat_taxithe |   File "/usr/local/lib/python3.6/site-packages/celery/beat.py", line 476, in setup_schedule
celery_beat_taxithe |     self._store = self._open_schedule()
celery_beat_taxithe |   File "/usr/local/lib/python3.6/site-packages/celery/beat.py", line 466, in _open_schedule
celery_beat_taxithe |     return self.persistence.open(self.schedule_filename, writeback=True)
celery_beat_taxithe |   File "/usr/local/lib/python3.6/shelve.py", line 243, in open
celery_beat_taxithe |     return DbfilenameShelf(filename, flag, protocol, writeback)
celery_beat_taxithe |   File "/usr/local/lib/python3.6/shelve.py", line 227, in __init__
celery_beat_taxithe |     Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
celery_beat_taxithe |   File "/usr/local/lib/python3.6/dbm/__init__.py", line 94, in open
celery_beat_taxithe |     return mod.open(file, flag, mode)
celery_beat_taxithe | _gdbm.error: Bad magic number

我的芹菜设置是:

CELERY_BEAT_SCHEDULE = {
    'driver_monitor_update_latlng': {
        'task': 'api.tasks.driver.turn_offline_driver',
        'schedule': 30.0 # a cada 30 seconds
    }
}

【问题讨论】:

  • 你试过用 crontab 吗?像这样: from celery.schedules import crontab CELERYBEAT_SCHEDULE = { 'run-every-20-min': { 'task': 'tasks.your-task', 'schedule': timedelta(minutes=20), 'args': () },
  • 是的,没有工作。当我使用 crontab 时,我收到此错误“尚未加载应用程序”。同样的我包括redis的depends_on,web app(django) e celery worker
  • 在我的机器上使用没有 crontab 的错误消息相同,但当我在 [2019-03-11 13:58:00,740: INFO 中看到 celery-beat 服务的日志时,任务将运行但在服务器中/MainProcess] 节拍:开始...

标签: python django docker celery


【解决方案1】:

尝试从 30.0 中删除 .0。可能不是问题,但这与您的号码或您处理号码的方式有关。

【讨论】:

  • 在文档中就像我的代码,但我删除并且问题继续存在:(
猜你喜欢
  • 2023-02-19
  • 2017-10-12
  • 2018-12-20
  • 2019-06-28
  • 2021-11-05
  • 2016-10-20
  • 1970-01-01
  • 2021-09-08
  • 2015-10-08
相关资源
最近更新 更多