cache.py 文件源码

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

项目:PowerSpikeGG 作者: PowerSpikeGG 项目源码 文件源码
def _connect(self, address, lazy_connection=False):
        """Set up a connection to the MongoDB server.

        Parameters:
            address: MongoDB server address.
            lazy_connection: avoid testing if the connection is working while
                initializing it.
        """
        client = pymongo.MongoClient(address,
            serverSelectionTimeoutMS=FLAGS.mongodb_connection_timeout)
        if lazy_connection:
            return client

        # Send a query to the server to see if the connection is working.
        try:
            client.server_info()
        except pymongo.errors.ServerSelectionTimeoutError as e:
            logging.error("Unable to connect to %s.", address)
            client = None

        return client
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号