改进vn.okcoin的断线重连功能
This commit is contained in:
parent
a431bf4353
commit
7b5e7c6ab0
@ -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()
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user