本文整理匯總了Python中mongo_connector.locking_dict.LockingDict.dict方法的典型用法代碼示例。如果您正苦於以下問題:Python LockingDict.dict方法的具體用法?Python LockingDict.dict怎麽用?Python LockingDict.dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mongo_connector.locking_dict.LockingDict
的用法示例。
在下文中一共展示了LockingDict.dict方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_upgrade_oplog_progress
# 需要導入模塊: from mongo_connector.locking_dict import LockingDict [as 別名]
# 或者: from mongo_connector.locking_dict.LockingDict import dict [as 別名]
def test_upgrade_oplog_progress(self):
first_oplog_ts1 = self.opman1.oplog.find_one()['ts']
first_oplog_ts2 = self.opman2.oplog.find_one()['ts']
# Old format oplog progress file:
progress = {
str(self.opman1.oplog): bson_ts_to_long(first_oplog_ts1),
str(self.opman2.oplog): bson_ts_to_long(first_oplog_ts2)
}
# Set up oplog managers to use the old format.
oplog_progress = LockingDict()
oplog_progress.dict = progress
self.opman1.oplog_progress = oplog_progress
self.opman2.oplog_progress = oplog_progress
# Cause the oplog managers to update their checkpoints.
self.opman1.update_checkpoint(first_oplog_ts1)
self.opman2.update_checkpoint(first_oplog_ts2)
# New format should be in place now.
new_format = {
self.opman1.replset_name: first_oplog_ts1,
self.opman2.replset_name: first_oplog_ts2
}
self.assertEqual(
new_format,
self.opman1.oplog_progress.get_dict()
)
self.assertEqual(
new_format,
self.opman2.oplog_progress.get_dict()
)