首页 > 解决方案 > Django Celery Beat 不执行旧任务

问题描述

celery -A appname worker -B --loglevel=debug -c 5

- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         appname:0x7f687c231a10
- ** ---------- .> transport:   amqp://guest:**@localhost:5672//
- ** ---------- .> results:     redis://localhost:6379/
- *** --- * --- .> concurrency: 5 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> mainqueue        exchange=mainqueue(direct) key=mainqueue
...
...
[2020-02-14 01:03:13,627: DEBUG/Beat] DatabaseScheduler: Fetching database scheduleESC[0m
[2020-02-14 01:03:13,639: DEBUG/MainProcess] Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True}, 'cluster_name': 'rabbit@kiraakdrop', 'copyright': 'Copyright (C) 2007-2015 Pivotal Software, Inc.', 'information': 'Licensed under the MPL.  See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP', 'product': 'RabbitMQ', 'version': '3.5.7'}, mechanisms: [b'AMQPLAIN', b'PLAIN'], locales: ['en_US']ESC[0m
[2020-02-14 01:03:13,642: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2020-02-14 01:03:13,643: DEBUG/MainProcess] ^-- substep okESC[0m
..
[2020-02-14 01:03:14,770: DEBUG/MainProcess] basic.qos: prefetch_count->20
[2020-02-14 01:03:14,841: DEBUG/Beat] Current schedule:
<ModelEntry: TASK-157-project run_project_task(*[], **{'p_id': 157}) <freq: 1.04 days>>
<ModelEntry: TASK-PROJ run_project2_task(*[], **{'pp_id': 4}) <freq: 7.00 hours>>

大约有 200 多个<ModelEntry: Task计划任务,但只有少数(40 个较新的任务)正在执行,而所有较旧的任务根本不执行,last_run没有,甚至监视flower也不会显示任务。每个间隔只执行较新的任务。而所有 200 多个任务都出现在django_celery_beat.schedulers:DatabaseScheduler.

######## CELERY : CONFIG
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True

### CELERY  CONFIG
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = "Asia/Kolkata"
CELERYBEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'
CELERY_TASK_SOFT_TIME_LIMIT = 4680
CELERY_TASK_TIME_LIMIT = 4800

标签: djangocelerydjango-celerycelerybeat

解决方案


推荐阅读