core.py 文件源码

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

项目:minion-ci 作者: timofurrer 项目源码 文件源码
def ensure_mongo(func):
    @wraps(func)
    def func_wrapper(*args, **kwargs):
        client = MongoClient(serverSelectionTimeoutMS=500, connectTimeoutMS=500)
        try:
             # The ismaster command is cheap and does not require auth.
            client.admin.command('ismaster')
        except (errors.ServerSelectionTimeoutError, errors.AutoReconnect):
            raise MinionMongoError("Can't connect to mongodb")
        else:
            return func(*args, **kwargs)
        finally:
            client.close()
    return func_wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号