当前位置: 首页>>代码示例>>Python>>正文


Python MongoReplicaSetClient.alive方法代码示例

本文整理汇总了Python中pymongo.mongo_replica_set_client.MongoReplicaSetClient.alive方法的典型用法代码示例。如果您正苦于以下问题:Python MongoReplicaSetClient.alive方法的具体用法?Python MongoReplicaSetClient.alive怎么用?Python MongoReplicaSetClient.alive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymongo.mongo_replica_set_client.MongoReplicaSetClient的用法示例。


在下文中一共展示了MongoReplicaSetClient.alive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_alive

# 需要导入模块: from pymongo.mongo_replica_set_client import MongoReplicaSetClient [as 别名]
# 或者: from pymongo.mongo_replica_set_client.MongoReplicaSetClient import alive [as 别名]
    def test_alive(self):
        primary = ha_tools.get_primary()
        secondary = ha_tools.get_random_secondary()
        primary_cx = MongoClient(primary, use_greenlets=use_greenlets)
        secondary_cx = MongoClient(secondary, use_greenlets=use_greenlets)
        rsc = MongoReplicaSetClient(
            self.seed, replicaSet=self.name, use_greenlets=use_greenlets)

        try:
            self.assertTrue(primary_cx.alive())
            self.assertTrue(secondary_cx.alive())
            self.assertTrue(rsc.alive())
    
            ha_tools.kill_primary()
            time.sleep(0.5)

            self.assertFalse(primary_cx.alive())
            self.assertTrue(secondary_cx.alive())
            self.assertFalse(rsc.alive())
            
            ha_tools.kill_members([secondary], 2)
            time.sleep(0.5)

            self.assertFalse(primary_cx.alive())
            self.assertFalse(secondary_cx.alive())
            self.assertFalse(rsc.alive())
        finally:
            rsc.close()
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:30,代码来源:test_ha.py

示例2: test_alive

# 需要导入模块: from pymongo.mongo_replica_set_client import MongoReplicaSetClient [as 别名]
# 或者: from pymongo.mongo_replica_set_client.MongoReplicaSetClient import alive [as 别名]
    def test_alive(self):
        client = self._get_client()
        self.assertTrue(client.alive())

        client = MongoReplicaSetClient("doesnt exist", replicaSet="rs", _connect=False)

        self.assertFalse(client.alive())
开发者ID:distagon,项目名称:Taiwan_Stock_info,代码行数:9,代码来源:test_replica_set_client.py

示例3: test_alive

# 需要导入模块: from pymongo.mongo_replica_set_client import MongoReplicaSetClient [as 别名]
# 或者: from pymongo.mongo_replica_set_client.MongoReplicaSetClient import alive [as 别名]
    def test_alive(self):
        client = MongoReplicaSetClient(
            'doesnt exist', replicaSet='rs', _connect=False)

        self.assertFalse(client.alive())
开发者ID:ArturFis,项目名称:mongo-python-driver,代码行数:7,代码来源:test_replica_set_client.py


注:本文中的pymongo.mongo_replica_set_client.MongoReplicaSetClient.alive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。