From bd7c6082b4bc4eb01f777bbfa9671362af009cbd Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 2 Dec 2017 21:46:05 +0800 Subject: [PATCH] [Fix]Close #525 --- vnpy/trader/app/dataRecorder/drEngine.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/app/dataRecorder/drEngine.py b/vnpy/trader/app/dataRecorder/drEngine.py index 198f1f22..bee7cef9 100644 --- a/vnpy/trader/app/dataRecorder/drEngine.py +++ b/vnpy/trader/app/dataRecorder/drEngine.py @@ -234,8 +234,14 @@ class DrEngine(object): while self.active: try: dbName, collectionName, d = self.queue.get(block=True, timeout=1) - flt = {'datetime': d['datetime']} - self.mainEngine.dbUpdate(dbName, collectionName, d, flt, True) + + # 这里采用MongoDB的update模式更新数据,在记录tick数据时会由于查询 + # 过于频繁,导致CPU占用和硬盘读写过高后系统卡死,因此不建议使用 + #flt = {'datetime': d['datetime']} + #self.mainEngine.dbUpdate(dbName, collectionName, d, flt, True) + + # 使用insert模式更新数据,可能存在时间戳重复的情况,需要用户自行清洗 + self.mainEngine.dbInsert(dbName, collectionName, d) except Empty: pass