(self, embedded_process=False)
| 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: |
| 1067 | debug('beat: Waking up %s.', |
| 1068 | humanize_seconds(interval, prefix='in ')) |
| 1069 | time.sleep(interval) |
| 1070 | if self.scheduler.should_sync(): |
| 1071 | self.scheduler._do_sync() |
| 1072 | except (KeyboardInterrupt, SystemExit): |
| 1073 | self._is_shutdown.set() |
| 1074 | finally: |
| 1075 | # Persist the schedule before spending time joining the |
| 1076 | # pidbox thread: a supervisor may follow SIGTERM with |
| 1077 | # SIGKILL, and the schedule is the state worth keeping. |
| 1078 | self.sync() |
| 1079 | if self._pidbox is not None: |
| 1080 | self._pidbox.stop() |
| 1081 | |
| 1082 | def sync(self): |
| 1083 | self.scheduler.close() |
no test coverage detected