MCPcopy Create free account
hub / github.com/celery/celery / Service

Class Service

celery/beat.py:1009–1104  ·  view source on GitHub ↗

Celery periodic task service.

Source from the content-addressed store, hash-verified

1007
1008
1009class Service:
1010 """Celery periodic task service."""
1011
1012 scheduler_cls = PersistentScheduler
1013
1014 def __init__(self, app, max_interval=None, schedule_filename=None,
1015 scheduler_cls=None, remote_control=None, hostname=None):
1016 self.app = app
1017 self.max_interval = (max_interval or
1018 app.conf.beat_max_loop_interval)
1019 self.scheduler_cls = scheduler_cls or self.scheduler_cls
1020 self.schedule_filename = (
1021 schedule_filename or app.conf.beat_schedule_filename)
1022 self.remote_control = (
1023 app.conf.beat_enable_remote_control
1024 if remote_control is None else remote_control)
1025 self.hostname = hostname
1026
1027 #: interval the scheduler settled on, recorded once it exists so
1028 #: the pidbox thread never has to build the lazy attribute.
1029 self.effective_max_interval = None
1030 self._pidbox = None
1031 #: monotonic timestamp of the last scheduler pass, read by the
1032 #: pidbox thread to decide whether beat is still ticking.
1033 self._last_tick = None
1034 self._is_shutdown = Event()
1035 self._is_stopped = Event()
1036
1037 def __reduce__(self):
1038 return self.__class__, (self.app, self.max_interval,
1039 self.schedule_filename, self.scheduler_cls,
1040 self.remote_control, self.hostname)
1041
1042 def start(self, embedded_process=False):
1043 info('beat: Starting...')
1044 debug('beat: Ticking with max interval->%s',
1045 humanize_seconds(self.scheduler.max_interval))
1046
1047 signals.beat_init.send(sender=self)
1048 if embedded_process:
1049 signals.beat_embedded_init.send(sender=self)
1050 platforms.set_process_title('celery beat')
1051
1052 self.effective_max_interval = self.scheduler.max_interval
1053
1054 if self.remote_control:
1055 self._pidbox = BeatPidbox(self)
1056 self._pidbox.start()
1057
1058 # Stamp before the first pass, so a beat that wedges before it
1059 # ever ticks goes stale rather than looking perpetually healthy.
1060 self._last_tick = time.monotonic()
1061
1062 try:
1063 while not self._is_shutdown.is_set():
1064 interval = self.scheduler.tick()
1065 self._last_tick = time.monotonic()
1066 if interval and interval > 0.0:

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected