defpatched_start(self, embedded_process=False): """ monkey patched start method, will skip tasks when standby flag is setted """ info('beat: Starting...') debug('beat: Ticking with max interval->%s', humanize_seconds(self.scheduler.max_interval))
signals.beat_init.send(sender=self) if embedded_process: signals.beat_embedded_init.send(sender=self) platforms.set_process_title('celery beat')
try: whilenot self._is_shutdown.is_set(): # patch starts from here if is_standby(): debug(f'beat: in standby mode, all tasks will be skipped, ' f'will check in [{STANDBY_CHECK_INTERVAL}] seconds') time.sleep(STANDBY_CHECK_INTERVAL) continue # patch ends interval = self.scheduler.tick() if interval and interval > 0.0: debug('beat: Waking up %s.', humanize_seconds(interval, prefix='in ')) time.sleep(interval) if self.scheduler.should_sync(): self.scheduler._do_sync() except (KeyboardInterrupt, SystemExit): self._is_shutdown.set() finally: self.sync()