tradingSystem/app/observation_worker.py

25 lines
783 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""ETF观测单进程入口,不启动交易worker或QMT连接。"""
import logging
import signal
from threading import Event
def main():
from app.services.etf_observation import consume_once
logging.basicConfig(level=logging.INFO)
stopping = Event()
signal.signal(signal.SIGTERM, lambda *_: stopping.set())
signal.signal(signal.SIGINT, lambda *_: stopping.set())
while not stopping.is_set():
try:
result = consume_once()
if result.get('status') == 'unavailable':
logging.warning('ETF观测暂不可用:%s', result.get('error'))
except Exception as exc:
logging.warning('ETF观测保存失败:%s', type(exc).__name__)
stopping.wait(15)
if __name__ == '__main__':
main()