Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Fix scheduled calls with Celery 4.x. #2968

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions server/pulp/server/async/scheduler.py
Expand Up @@ -6,7 +6,7 @@
import threading
import time

from celery import beat
from celery import beat, __version__ as celery_version
import mongoengine

from pulp.common import constants
Expand Down Expand Up @@ -199,6 +199,9 @@ def tick(self):
"""
worker_watcher.handle_worker_heartbeat(CELERYBEAT_NAME)

if celery_version.startswith('4') and self.schedule_changed:
self._heap = None

now = ensure_tz(datetime.utcnow())
old_timestamp = now - timedelta(seconds=constants.PULP_PROCESS_TIMEOUT_INTERVAL)

Expand Down Expand Up @@ -253,7 +256,13 @@ def setup_schedule(self):
Scheduler._mongo_initialized = True
_logger.debug(_('loading schedules from app'))
self._schedule = {}
for key, value in self.app.conf.CELERYBEAT_SCHEDULE.iteritems():

if celery_version.startswith('4'):
items = self.app.conf.beat_schedule.iteritems()
else:
items = self.app.conf.CELERYBEAT_SCHEDULE.iteritems()

for key, value in items:
self._schedule[key] = beat.ScheduleEntry(**dict(value, name=key))

# include a "0" as the default in case there are no schedules to load
Expand Down