mongo_proxy.py 文件源码

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

项目:lightflow 作者: AustralianSynchrotron 项目源码 文件源码
def __call__(self, *args, **kwargs):
        """ Call the method and handle the AutoReconnect exception gracefully """
        start_time = time.time()

        for attempt in count():
            try:
                return self._method(*args, **kwargs)
            except AutoReconnect:
                duration = time.time() - start_time

                if duration >= WAIT_TIME:
                    break

                logger.warning(
                    'Reconnecting to MongoDB, attempt {} ({:.3f} seconds elapsed)'.
                    format(attempt, duration))

                time.sleep(self.calc_sleep(attempt))

        return self._method(*args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号