改进vn.okcoin的断线重连功能

This commit is contained in:
chenxy123 2016-12-02 23:50:35 +08:00
parent a431bf4353
commit 7b5e7c6ab0
2 changed files with 5 additions and 4 deletions

View File

@ -185,7 +185,7 @@ class OkCoinApi(object):
#----------------------------------------------------------------------
def close(self):
"""关闭接口"""
if self.thread and self.thread.isAlive:
if self.thread and self.thread.isAlive():
self.ws.close()
self.thread.join()

View File

@ -108,7 +108,8 @@ class OkcoinGateway(VtGateway):
"""连接"""
# 载入json文件
fileName = self.gatewayName + '_connect.json'
fileName = os.getcwd() + '/okcoinGateway/' + fileName
path = os.path.abspath(os.path.dirname(__file__))
fileName = os.path.join(path, fileName)
try:
f = file(fileName)
@ -278,9 +279,9 @@ class Api(vnokcoin.OkCoinApi):
# 重新连接
if self.active:
print 'start reconnect'
self.writeLog(u'等待5秒后重新连接')
sleep(5)
self.reconnect()
print 'reconnected'
#----------------------------------------------------------------------
def onOpen(self, ws):