cache.py 文件源码

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

项目:PowerSpikeGG 作者: PowerSpikeGG 项目源码 文件源码
def _silent_connection_failure(func):
    """Decorator used to avoid raising an exception when the database timeouts

    Parameters:
        func: Function to decorate.
    """
    @wraps(func)
    def wrapper(*args, **kwargs):
        """Wraps the function to catch timeout exception.
        """
        if not FLAGS.disable_mongodb_exception:
            return func(*args, **kwargs)

        try:
            result = func(*args, **kwargs)
        except pymongo.errors.ServerSelectionTimeoutError as e:
            logging.error("Unable to reach the caching server: %s", e)
            return None
        return result

    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号