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


Python ReplicaSetConnection.end_request方法代码示例

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


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

示例1: test_replica_set_connection

# 需要导入模块: from pymongo.replica_set_connection import ReplicaSetConnection [as 别名]
# 或者: from pymongo.replica_set_connection.ReplicaSetConnection import end_request [as 别名]
    def test_replica_set_connection(self):
        c = ReplicaSetConnection(pair, replicaSet=self.name)

        ctx = catch_warnings()
        try:
            warnings.simplefilter("ignore", DeprecationWarning)
            self.assertTrue(c.auto_start_request)
            self.assertEqual(None, c.max_pool_size)
            self.assertFalse(c.slave_okay)
            self.assertFalse(c.safe)
            self.assertEqual({}, c.get_lasterror_options())

            # ReplicaSetConnection's writes are unacknowledged by default
            doc = {"_id": ObjectId()}
            coll = c.pymongo_test.write_concern_test
            coll.drop()
            coll.insert(doc)
            coll.insert(doc)

            c = ReplicaSetConnection("mongodb://%s:%s/?replicaSet=%s&safe=true" % (
                host, port, self.name))

            self.assertTrue(c.safe)
        finally:
            ctx.exit()

        # To preserve legacy ReplicaSetConnection's behavior, max_size should
        # be None. Pool should handle this without error.
        pool = get_pool(c)
        self.assertEqual(None, pool.max_size)
        c.end_request()

        # ReplicaSetConnection's network_timeout argument is translated into
        # socketTimeoutMS
        self.assertEqual(123, ReplicaSetConnection(
            pair, replicaSet=self.name, network_timeout=123
        )._MongoReplicaSetClient__net_timeout)

        for network_timeout in 'foo', 0, -1:
            self.assertRaises(
                ConfigurationError,
                ReplicaSetConnection, pair, replicaSet=self.name,
                network_timeout=network_timeout)
开发者ID:hedgepigdaniel,项目名称:mongo-python-driver,代码行数:45,代码来源:test_legacy_connections.py


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