代码拉取完成,页面将自动刷新
import pymongo
import math
class CSaveManager(object):
def __init__(self):
self.m_SaveList = []
def OnSaveLoop(self):
if not self.m_SaveList:
return
iSaveCnt = math.ceil(len(self.m_SaveList)/300)
lstSave = self.m_SaveList[:iSaveCnt]
self.m_SaveList = self.m_SaveList[iSaveCnt:]
for oSaveObj in lstSave:
oSaveObj.OnSave()
class CSaveObj(object):
m_ColName = ""
def __init__(self, iID):
self.m_ID = iID
def Save(self):
data = {}
data["ID"] = self.m_ID
return data
def Load(self, data):
pass
def OnSave(self):
pass
class CMongosClient(object):
def __init__(self):
self.m_SaveList = []
oClient = pymongo.MongoClient("mongodb://localhost:27017/")
self.m_MyDB = oClient["testdb0"]
def AddSaveData(self, sCol, data):
self.m_SaveList.append((sCol, data))
def SaveLoop(self):
while True:
if self.m_SaveList:
sCol, data = self.m_SaveList.pop(0)
self.m_MyDB[sCol].update_one(data)
def Init():
global g_SaveManager
g_SaveManager = CSaveManager()
def GetSaveManager():
global g_SaveManager
return g_SaveManager
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。