[Add]WebTrader增加习题用信号退出机制
This commit is contained in:
parent
9fdfb253f0
commit
d3302c2a75
@ -13,7 +13,10 @@ from vnpy.trader.app import dataRecorder
|
|||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def processErrorEvent(event):
|
def processErrorEvent(event):
|
||||||
"""处理错误事件"""
|
"""
|
||||||
|
处理错误事件
|
||||||
|
错误信息在每次登陆后,会将当日所有已产生的均推送一遍,所以不适合写入日志
|
||||||
|
"""
|
||||||
error = event.dict_['data']
|
error = event.dict_['data']
|
||||||
print u'错误代码:%s,错误信息:%s' %(error.errorID, error.errorMsg)
|
print u'错误代码:%s,错误信息:%s' %(error.errorID, error.errorMsg)
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import sys
|
|||||||
reload(sys)
|
reload(sys)
|
||||||
sys.setdefaultencoding('utf8')
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
|
import signal
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
# vn.trader模块
|
# vn.trader模块
|
||||||
@ -35,6 +36,10 @@ def main():
|
|||||||
# 创建主引擎
|
# 创建主引擎
|
||||||
me = MainEngine(ee)
|
me = MainEngine(ee)
|
||||||
|
|
||||||
|
# 安全退出机制
|
||||||
|
for sig in [signal.SIGINT, signal.SIGHUP, signal.SIGTERM]:
|
||||||
|
signal.signal(sig, me.exit)
|
||||||
|
|
||||||
# 添加交易接口
|
# 添加交易接口
|
||||||
me.addGateway(ctpGateway)
|
me.addGateway(ctpGateway)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user