Пример #1
0
    def test_humanize_seconds(self):
        t = ((4 * 60 * 60 * 24, "4 days"),
             (1 * 60 * 60 * 24, "1 day"),
             (4 * 60 * 60, "4 hours"),
             (1 * 60 * 60, "1 hour"),
             (4 * 60, "4 minutes"),
             (1 * 60, "1 minute"),
             (4, "4.00 seconds"),
             (1, "1.00 second"),
             (4.3567631221, "4.36 seconds"),
             (0, "now"))

        for seconds, human in t:
            self.assertEquals(info.humanize_seconds(seconds), human)

        self.assertEquals(info.humanize_seconds(4, prefix="about "),
                          "about 4.00 seconds")
Пример #2
0
    def start(self):
        self.logger.info("ClockService: Starting...")
        self.logger.debug(
            "ClockService: "
            "Ticking with max interval->%s, schedule->%s"
            % (humanize_seconds(self.max_interval), self.schedule_filename)
        )

        try:
            while True:
                if self._shutdown.isSet():
                    break
                interval = self.scheduler.tick()
                self.debug("ClockService: Waking up %s." % (humanize_seconds(interval, prefix="in ")))
                time.sleep(interval)
        except (KeyboardInterrupt, SystemExit):
            self.sync()
        finally:
            self.sync()
Пример #3
0
    def start(self, embedded_process=False):
        self.logger.info("Celerybeat: Starting...")
        self.logger.debug("Celerybeat: "
            "Ticking with max interval->%s" % (
                    humanize_seconds(self.scheduler.max_interval)))

        if embedded_process:
            platforms.set_process_title("celerybeat")

        try:
            try:
                while not self._shutdown.isSet():
                    interval = self.scheduler.tick()
                    self.debug("Celerybeat: Waking up %s." % (
                            humanize_seconds(interval, prefix="in ")))
                    time.sleep(interval)
            except (KeyboardInterrupt, SystemExit):
                self._shutdown.set()
        finally:
            self.sync()
Пример #4
0
    def start(self, embedded_process=False):
        self.logger.info("Celerybeat: Starting...")
        self.logger.debug("Celerybeat: "
            "Ticking with max interval->%s" % (
                    humanize_seconds(self.scheduler.max_interval)))

        if embedded_process:
            platforms.set_process_title("celerybeat")

        try:
            try:
                while not self._shutdown.isSet():
                    interval = self.scheduler.tick()
                    self.debug("Celerybeat: Waking up %s." % (
                            humanize_seconds(interval, prefix="in ")))
                    time.sleep(interval)
            except (KeyboardInterrupt, SystemExit):
                self._shutdown.set()
        finally:
            self.sync()
Пример #5
0
 def startup_info(self, beat):
     return STARTUP_INFO_FMT % {
         "conninfo": info.format_broker_info(),
         "logfile": self.logfile or "[stderr]",
         "loglevel": LOG_LEVELS[self.loglevel],
         "loader": get_full_cls_name(self.loader.__class__),
         "scheduler": get_full_cls_name(beat.scheduler.__class__),
         "scheduler_info": beat.scheduler.info,
         "hmax_interval": humanize_seconds(beat.max_interval),
         "max_interval": beat.max_interval,
     }