コード例 #1
0
ファイル: suite.py プロジェクト: alexfive/celery
def pstatus(p):
    runtime = monotonic() - p.runtime
    elapsed = monotonic() - p.elapsed
    return F_PROGRESS.format(
        p,
        runtime=humanize_seconds(runtime, now=runtime),
        elapsed=humanize_seconds(elapsed, now=elapsed),
    )
コード例 #2
0
def pstatus(p):
    runtime = monotonic() - p.runtime
    elapsed = monotonic() - p.elapsed
    return F_PROGRESS.format(
        p,
        runtime=humanize_seconds(runtime, now=runtime),
        elapsed=humanize_seconds(elapsed, now=elapsed),
    )
コード例 #3
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.assertEqual(humanize_seconds(seconds), human)

        self.assertEqual(humanize_seconds(4, prefix="about "),
                         "about 4.00 seconds")
コード例 #4
0
    def test_humanize_seconds(self):
        t = ((4 * 60 * 60 * 24, '4.00 days'), (1 * 60 * 60 * 24, '1.00 day'),
             (4 * 60 * 60, '4.00 hours'), (1 * 60 * 60, '1.00 hour'),
             (4 * 60, '4.00 minutes'), (1 * 60,
                                        '1.00 minute'), (4, '4.00 seconds'),
             (1, '1.00 second'), (4.3567631221, '4.36 seconds'), (0, 'now'))

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

        self.assertEqual(humanize_seconds(4, prefix='about '),
                         'about 4.00 seconds')
コード例 #5
0
 def info(self):
     info = ['       . redis -> {}'.format(self.app.redbeat_conf.redis_url)]
     if self.lock_key:
         info.append('       . lock -> `{}` {} ({}s)'.format(
             self.lock_key, humanize_seconds(self.lock_timeout),
             self.lock_timeout))
     return '\n'.join(info)
コード例 #6
0
ファイル: schedulers.py プロジェクト: mmadsen/redbeat
 def info(self):
     info = ['       . redis -> {}'.format(self.app.conf.REDBEAT_REDIS_URL)]
     if self.lock_key:
         info.append('       . lock -> `{}` {} ({}s)'.format(
             self.lock_key, humanize_seconds(self.lock_timeout),
             self.lock_timeout))
     return '\n'.join(info)
コード例 #7
0
ファイル: suite.py プロジェクト: SalesSeek/celery
 def runtest(self, fun, n=50, index=0, repeats=1):
     with blockdetection(self.block_timeout):
         t = time()
         i = 0
         failed = False
         self.progress = Progress(fun, i, n, index, repeats, t, 0)
         _marker.delay(pstatus(self.progress))
         try:
             for i in range(n):
                 self.progress = Progress(fun, i, n, index, repeats, t, 0)
                 print(pstatus(self.progress), end=' ')
                 try:
                     fun()
                     print('-> done')
                 except Exception as exc:
                     print('-> {0!r}'.format(exc))
         except Exception:
             failed = True
             raise
         finally:
             print('{0} {1} iterations in {2}s'.format(
                 'failed after' if failed else 'completed',
                 i + 1, humanize_seconds(time() - t),
             ))
             if not failed:
                 self.progress = Progress(fun, i, n, index, repeats, t, 1)
コード例 #8
0
ファイル: suite.py プロジェクト: adamchainz/cyanide
def humanize_seconds(secs, prefix='', sep='', now='now', **kwargs):
    s = timeutils.humanize_seconds(secs, prefix, sep, now, **kwargs)
    if s == now and secs > 0:
        return '{prefix}{sep}{0:.2f} seconds'.format(float(secs),
                                                     prefix=prefix,
                                                     sep=sep)
    return s
コード例 #9
0
 def runtest(self, fun, n=50, index=0, repeats=1):
     with blockdetection(self.block_timeout):
         t = time()
         i = 0
         failed = False
         self.progress = Progress(fun, i, n, index, repeats, t, 0)
         _marker.delay(pstatus(self.progress))
         try:
             for i in range(n):
                 self.progress = Progress(fun, i, n, index, repeats, t, 0)
                 print(pstatus(self.progress), end=' ')
                 try:
                     fun()
                     print('-> done')
                 except Exception as exc:
                     print('-> {0!r}'.format(exc))
         except Exception:
             failed = True
             raise
         finally:
             print('{0} {1} iterations in {2}s'.format(
                 'failed after' if failed else 'completed',
                 i + 1,
                 humanize_seconds(time() - t),
             ))
             if not failed:
                 self.progress = Progress(fun, i, n, index, repeats, t, 1)
コード例 #10
0
ファイル: test_timeutils.py プロジェクト: charettes/celery
    def test_humanize_seconds(self):
        t = ((4 * 60 * 60 * 24, '4.00 days'),
             (1 * 60 * 60 * 24, '1.00 day'),
             (4 * 60 * 60, '4.00 hours'),
             (1 * 60 * 60, '1.00 hour'),
             (4 * 60, '4.00 minutes'),
             (1 * 60, '1.00 minute'),
             (4, '4.00 seconds'),
             (1, '1.00 second'),
             (4.3567631221, '4.36 seconds'),
             (0, 'now'))

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

        self.assertEqual(humanize_seconds(4, prefix='about '),
                         'about 4.00 seconds')
コード例 #11
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.assertEqual(timeutils.humanize_seconds(seconds), human)

        self.assertEqual(timeutils.humanize_seconds(4, prefix="about "),
                          "about 4.00 seconds")
コード例 #12
0
ファイル: consumer.py プロジェクト: niteoweb/celery3
 def _error_handler(exc, interval, next_step=CONNECTION_RETRY_STEP):
     if getattr(conn, "alt", None) and interval == 0:
         next_step = CONNECTION_FAILOVER
     error(
         CONNECTION_ERROR,
         conn.as_uri(),
         exc,
         next_step.format(when=humanize_seconds(interval, "in", " ")),
     )
コード例 #13
0
ファイル: schedulers.py プロジェクト: sibson/redbeat
 def info(self):
     info = ["       . redis -> {}".format(self.app.conf.REDBEAT_REDIS_URL)]
     if self.lock_key:
         info.append(
             "       . lock -> `{}` {} ({}s)".format(
                 self.lock_key, humanize_seconds(self.lock_timeout), self.lock_timeout
             )
         )
     return "\n".join(info)
コード例 #14
0
ファイル: beat.py プロジェクト: berg/celery
    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()
コード例 #15
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)))

        signals.beat_init.send(sender=self)
        if embedded_process:
            signals.beat_embedded_init.send(sender=self)
            platforms.set_process_title("celerybeat")

        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()
コード例 #16
0
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT % {
         'conninfo': self.app.connection().as_uri(),
         'logfile': self.logfile or '[stderr]',
         'loglevel': LOG_LEVELS[self.loglevel],
         'loader': qualname(self.app.loader),
         'scheduler': qualname(scheduler),
         'scheduler_info': scheduler.info,
         'hmax_interval': humanize_seconds(beat.max_interval),
         'max_interval': beat.max_interval,
     }
コード例 #17
0
ファイル: beat.py プロジェクト: Fak3/celery
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT.format(
         conninfo=self.app.connection().as_uri(),
         logfile=self.logfile or '[stderr]',
         loglevel=LOG_LEVELS[self.loglevel],
         loader=qualname(self.app.loader),
         scheduler=qualname(scheduler),
         scheduler_info=scheduler.info,
         hmax_interval=humanize_seconds(beat.max_interval),
         max_interval=beat.max_interval,
         )
コード例 #18
0
ファイル: beat.py プロジェクト: SYNchroACK/crits_dependencies
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT % {
         'conninfo': self.app.connection().as_uri(),
         'logfile': self.logfile or '[stderr]',
         'loglevel': LOG_LEVELS[self.loglevel],
         'loader': qualname(self.app.loader),
         'scheduler': qualname(scheduler),
         'scheduler_info': scheduler.info,
         'hmax_interval': humanize_seconds(beat.max_interval),
         'max_interval': beat.max_interval,
     }
コード例 #19
0
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT.format(
         conninfo=self.app.connection().as_uri(),
         logfile=self.logfile or '[stderr]',
         loglevel=LOG_LEVELS[self.loglevel],
         loader=qualname(self.app.loader),
         scheduler=qualname(scheduler),
         scheduler_info=scheduler.info,
         hmax_interval=humanize_seconds(beat.max_interval),
         max_interval=beat.max_interval,
     )
コード例 #20
0
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT % {
         "conninfo": self.app.broker_connection().as_uri(),
         "logfile": self.logfile or "[stderr]",
         "loglevel": LOG_LEVELS[self.loglevel],
         "loader": get_full_cls_name(self.app.loader.__class__),
         "scheduler": get_full_cls_name(scheduler.__class__),
         "scheduler_info": scheduler.info,
         "hmax_interval": humanize_seconds(beat.max_interval),
         "max_interval": beat.max_interval,
     }
コード例 #21
0
ファイル: beat.py プロジェクト: berg/celery
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT % {
         "conninfo": self.app.amqp.format_broker_info(),
         "logfile": self.logfile or "[stderr]",
         "loglevel": LOG_LEVELS[self.loglevel],
         "loader": get_full_cls_name(self.app.loader.__class__),
         "scheduler": get_full_cls_name(scheduler.__class__),
         "scheduler_info": scheduler.info,
         "hmax_interval": humanize_seconds(beat.max_interval),
         "max_interval": beat.max_interval,
     }
コード例 #22
0
ファイル: beat.py プロジェクト: AdrianRibao/celery
 def startup_info(self, beat):
     scheduler = beat.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT % {
         "conninfo": self.app.broker_connection().as_uri(),
         "logfile": self.logfile or "[stderr]",
         "loglevel": LOG_LEVELS[self.loglevel],
         "loader": qualname(self.app.loader),
         "scheduler": qualname(scheduler),
         "scheduler_info": scheduler.info,
         "hmax_interval": humanize_seconds(beat.max_interval),
         "max_interval": beat.max_interval,
     }
コード例 #23
0
 def startup_info(self, service):
     scheduler = service.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT.format(
         conninfo=self.app.connection().as_uri(),
         timestamp=datetime.now().replace(microsecond=0),
         logfile=self.logfile or '[stderr]',
         loglevel=LOG_LEVELS[self.loglevel],
         loader=qualname(self.app.loader),
         scheduler=qualname(scheduler),
         scheduler_info=scheduler.info,
         hmax_interval=humanize_seconds(service.max_interval),
         max_interval=service.max_interval,
     )
コード例 #24
0
ファイル: beat.py プロジェクト: MichaelAquilina/celery
 def startup_info(self, service):
     scheduler = service.get_scheduler(lazy=True)
     return STARTUP_INFO_FMT.format(
         conninfo=self.app.connection().as_uri(),
         timestamp=datetime.now().replace(microsecond=0),
         logfile=self.logfile or '[stderr]',
         loglevel=LOG_LEVELS[self.loglevel],
         loader=qualname(self.app.loader),
         scheduler=qualname(scheduler),
         scheduler_info=scheduler.info,
         hmax_interval=humanize_seconds(service.max_interval),
         max_interval=service.max_interval,
     )
コード例 #25
0
ファイル: suite.py プロジェクト: alexfive/celery
 def runtest(self, fun, n=50, index=0, repeats=1):
     n = getattr(fun, '__iterations__', None) or n
     print('{0}: [[[{1}({2})]]]'.format(repeats, fun.__name__, n))
     with blockdetection(self.block_timeout):
         with self.fbi.investigation():
             runtime = elapsed = monotonic()
             i = 0
             failed = False
             self.progress = Progress(
                 fun, i, n, index, repeats, elapsed, runtime, 0,
             )
             _marker.delay(pstatus(self.progress))
             try:
                 for i in range(n):
                     runtime = monotonic()
                     self.progress = Progress(
                         fun, i + 1, n, index, repeats, runtime, elapsed, 0,
                     )
                     try:
                         fun()
                     except StopSuite:
                         raise
                     except Exception as exc:
                         print('-> {0!r}'.format(exc))
                         import traceback
                         print(traceback.format_exc())
                         print(pstatus(self.progress))
                     else:
                         print(pstatus(self.progress))
             except Exception:
                 failed = True
                 self.speaker.beep()
                 raise
             finally:
                 print('{0} {1} iterations in {2}'.format(
                     'failed after' if failed else 'completed',
                     i + 1, humanize_seconds(monotonic() - elapsed),
                 ))
                 if not failed:
                     self.progress = Progress(
                         fun, i + 1, n, index, repeats, runtime, elapsed, 1,
                     )
コード例 #26
0
 def runtest(self, fun, n=50, index=0, repeats=1):
     print('{0}: [[[{1}({2})]]]'.format(repeats, fun.__name__, n))
     with blockdetection(self.block_timeout):
         with self.fbi.investigation():
             runtime = elapsed = monotonic()
             i = 0
             failed = False
             self.progress = Progress(
                 fun, i, n, index, repeats, elapsed, runtime, 0,
             )
             _marker.delay(pstatus(self.progress))
             try:
                 for i in range(n):
                     runtime = monotonic()
                     self.progress = Progress(
                         fun, i + 1, n, index, repeats, runtime, elapsed, 0,
                     )
                     try:
                         fun()
                     except StopSuite:
                         raise
                     except Exception as exc:
                         print('-> {0!r}'.format(exc))
                         print(pstatus(self.progress))
                     else:
                         print(pstatus(self.progress))
             except Exception:
                 failed = True
                 self.speaker.beep()
                 raise
             finally:
                 print('{0} {1} iterations in {2}s'.format(
                     'failed after' if failed else 'completed',
                     i + 1, humanize_seconds(monotonic() - elapsed),
                 ))
                 if not failed:
                     self.progress = Progress(
                         fun, i + 1, n, index, repeats, runtime, elapsed, 1,
                     )
コード例 #27
0
 def runtest(self, fun, n=50, index=0):
     with blockdetection(self.block_timeout):
         t = time()
         i = 0
         failed = False
         marker('{0}: {1}({2})'.format(index, fun.__name__, n))
         try:
             for i in range(n):
                 print('{0} ({1})'.format(i, fun.__name__), end=' ')
                 try:
                     fun()
                     print('-> done')
                 except Exception as exc:
                     print('-> {}'.format(exc))
         except Exception:
             failed = True
             raise
         finally:
             print('{0} {1} iterations in {2}s'.format(
                 'failed after' if failed else 'completed',
                 i + 1, humanize_seconds(time() - t),
             ))
コード例 #28
0
 def on_connection_error(self, max_retries, exc, intervals, retries):
     tts = next(intervals)
     error('Connection to Redis lost: Retry (%s/%s) %s.', retries,
           max_retries or 'Inf', humanize_seconds(tts, 'in '))
     return tts
コード例 #29
0
 def _error_handler(exc, interval):
     dumper.say(CONNECTION_ERROR %
                (conn.as_uri(), exc, humanize_seconds(interval, 'in', ' ')))
コード例 #30
0
ファイル: redis.py プロジェクト: buendiya/celery
 def on_connection_error(self, max_retries, exc, intervals, retries):
     tts = next(intervals)
     error(E_LOST, retries, max_retries or 'Inf',
           humanize_seconds(tts, 'in '))
     return tts
コード例 #31
0
ファイル: redis.py プロジェクト: MagicSolutions/celery
 def on_connection_error(self, max_retries, exc, intervals, retries):
     tts = next(intervals)
     error('Connection to Redis lost: Retry (%s/%s) %s.',
           retries, max_retries or 'Inf',
           humanize_seconds(tts, 'in '))
     return tts
コード例 #32
0
ファイル: suite.py プロジェクト: 343829084/celery
def pstatus(p):
    return F_PROGRESS.format(
        p,
        runtime=humanize_seconds(monotonic() - p.runtime, now='0 seconds'),
        elapsed=humanize_seconds(monotonic() - p.elapsed, now='0 seconds'),
    )
コード例 #33
0
 def _error_handler(exc, interval, next_step=CONNECTION_RETRY):
     if getattr(conn, 'alt', None) and interval == 0:
         next_step = CONNECTION_FAILOVER
     error(CONNECTION_ERROR, conn.as_uri(), exc,
           next_step.format(when=humanize_seconds(interval, 'in', ' ')))
コード例 #34
0
def pstatus(p):
    return F_PROGRESS.format(
        p,
        runtime=humanize_seconds(monotonic() - p.runtime, now='0 seconds'),
        elapsed=humanize_seconds(monotonic() - p.elapsed, now='0 seconds'),
    )
コード例 #35
0
ファイル: consumer.py プロジェクト: Crowdbooster/celery
 def _error_handler(exc, interval, next_step=CONNECTION_RETRY):
     if getattr(conn, "alt", None) and interval == 0:
         next_step = CONNECTION_FAILOVER
     error(CONNECTION_ERROR, conn.as_uri(), exc, next_step % {"when": humanize_seconds(interval, "in", " ")})
コード例 #36
0
ファイル: redis.py プロジェクト: xyzonline/celery
 def on_connection_error(self, max_retries, exc, intervals, retries):
     tts = next(intervals)
     error(E_LOST, retries, max_retries or 'Inf',
           humanize_seconds(tts, 'in '))
     return tts
コード例 #37
0
ファイル: schedules.py プロジェクト: colinhowe/celery
 def __repr__(self):
     return "<freq: %s>" % humanize_seconds(
             timedelta_seconds(self.run_every))
コード例 #38
0
ファイル: suite.py プロジェクト: SalesSeek/celery
def pstatus(p):
    return F_PROGRESS.format(
        p, since=humanize_seconds(time() - p.when, now='0 seconds'))
コード例 #39
0
ファイル: schedules.py プロジェクト: mozilla/webifyme-lib
 def __repr__(self):
     return "<freq: %s>" % humanize_seconds(
         timedelta_seconds(self.run_every))
コード例 #40
0
ファイル: schedulers.py プロジェクト: galileo-press/redbeat
 def info(self):
     info = ['       . redis -> {}'.format(self.app.conf.REDBEAT_REDIS_URL)]
     if self.lock_key:
         info.append('       . lock -> `{}` {} ({}s)'.format(
             self.lock_key, humanize_seconds(self.lock_timeout), self.lock_timeout))
     return '\n'.join(info)
コード例 #41
0
def pstatus(p):
    return F_PROGRESS.format(p,
                             since=humanize_seconds(time() - p.when,
                                                    now='0 seconds'))
コード例 #42
0
ファイル: suite.py プロジェクト: adamchainz/cyanide
def humanize_seconds(secs, prefix='', sep='', now='now', **kwargs):
    s = timeutils.humanize_seconds(secs, prefix, sep, now, **kwargs)
    if s == now and secs > 0:
        return '{prefix}{sep}{0:.2f} seconds'.format(
            float(secs), prefix=prefix, sep=sep)
    return s
コード例 #43
0
ファイル: consumer.py プロジェクト: frol/celery
 def _error_handler(exc, interval, next_step=CONNECTION_RETRY_STEP):
     if getattr(conn, 'alt', None) and interval == 0:
         next_step = CONNECTION_FAILOVER
     error(CONNECTION_ERROR, conn.as_uri(), exc,
           next_step.format(when=humanize_seconds(interval, 'in', ' ')))
コード例 #44
0
ファイル: dumper.py プロジェクト: Birdbird/celery
 def _error_handler(exc, interval):
     dumper.say(CONNECTION_ERROR % (
         conn.as_uri(), exc, humanize_seconds(interval, 'in', ' ')
     ))