Skip to content

Commit

Permalink
- fix : 修正了重复类型的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
lamter committed Aug 19, 2016
1 parent 30f8948 commit 0f7ba5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions easyquant/main_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, broker=None, need_data=None, quotation_engines=None,
quotation_engines = [quotation_engines]
else:
types = [quo.EventType for quo in quotation_engines]
if len(types) != set(types):
if len(types) != len(set(types)):
types.sort()
types = ','.join([str(t) for t in types])
raise ValueError("行情引擎 EventType 重复:" + types)
Expand Down Expand Up @@ -252,6 +252,7 @@ def _shutdown(self, sig, frame):
关闭进程前的处理
:return:
"""
self.log.debug("开始关闭进程...")
# 所有 shutdown 前的触发点
for st in self.before_shutdown:
st()
Expand All @@ -262,10 +263,11 @@ def _shutdown(self, sig, frame):

# 等待所有线程关闭, 直到只留下主线程
c = threading.active_count()
while threading.active_count() == c:
while threading.active_count() != c:
time.sleep(2)

# 调用策略的 shutdown
self.log.debug("开始关闭策略...")
for s in self.strategy_list:
s.shutdown()

Expand Down
2 changes: 1 addition & 1 deletion strategies/策略1_Demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def clock(self, event):

def log_handler(self):
"""自定义 log 记录方式"""
return DefaultLogHandler(self.name, log_type='file', filepath='demo1.log')
return DefaultLogHandler(self.name, log_type='stdout', filepath='demo1.log')

def shutdown(self):
"""
Expand Down

0 comments on commit 0f7ba5c

Please sign in to comment.