修复MongoDB连接bug

修复在MongoDB服务端异常情况下,启动vnpy依然显示MongoDB连接成功bug。
修改‘serverSelectionTimeoutMS’为3s(默认30s), 利用server_info()函数测试服务器是否正常。
This commit is contained in:
qzbysh 2016-05-18 21:15:58 +08:00
parent 9f083dc0d8
commit 0a0a9cda1a

View File

@ -208,7 +208,8 @@ class MainEngine(object):
host, port = loadMongoSetting() host, port = loadMongoSetting()
try: try:
self.dbClient = MongoClient(host, port) self.dbClient = MongoClient(host, port, serverSelectionTimeoutMS=3000)
self.dbClient.server_info()
self.writeLog(u'MongoDB连接成功') self.writeLog(u'MongoDB连接成功')
except ConnectionFailure: except ConnectionFailure:
self.writeLog(u'MongoDB连接失败') self.writeLog(u'MongoDB连接失败')