heartbeat.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:antenna 作者: mozilla-services 项目源码 文件源码
def heartbeat(self):
        """Heartbeat function

        Every hearbeat_interval seconds, runs registered functions. This will
        capture unhandled exceptions and report them.

        """
        # Keep beating unless the WSGI worker is shutting down
        while self.is_alive():
            logger.debug('thump')
            self._heartbeat_beat_once()
            gevent.sleep(self.heartbeat_interval)

        logger.info('App stopped, so stopping heartbeat.')

        # We're at worker shutdown, so beat until all registered lifers are ok
        # with us shutting down
        while any([fun() for fun in _registered_lifers]):
            logger.debug('thump (finishing up)')
            self._heartbeat_beat_once()

            # Faster beat so we can shutdown sooner
            gevent.sleep(1)

        logger.info('Everything completed.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号