修复MongoDB连接bug
修复在MongoDB服务端异常情况下,启动vnpy依然显示MongoDB连接成功bug。 修改‘serverSelectionTimeoutMS’为3s(默认30s), 利用server_info()函数测试服务器是否正常。
This commit is contained in:
parent
9f083dc0d8
commit
0a0a9cda1a
@ -208,7 +208,8 @@ class MainEngine(object):
|
||||
host, port = loadMongoSetting()
|
||||
|
||||
try:
|
||||
self.dbClient = MongoClient(host, port)
|
||||
self.dbClient = MongoClient(host, port, serverSelectionTimeoutMS=3000)
|
||||
self.dbClient.server_info()
|
||||
self.writeLog(u'MongoDB连接成功')
|
||||
except ConnectionFailure:
|
||||
self.writeLog(u'MongoDB连接失败')
|
||||
|
Loading…
Reference in New Issue
Block a user