本文整理汇总了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)