32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""ETF观测单进程入口,不启动交易worker或QMT连接。"""
|
||
import logging
|
||
import signal
|
||
from threading import Event
|
||
|
||
|
||
def main():
|
||
from app.services.etf_observation import consume_once
|
||
from app.services.broad_funds import consume_once as consume_daily
|
||
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__)
|
||
try:
|
||
result = consume_daily()
|
||
if result.get('status') == 'unavailable':
|
||
logging.warning('每日资金暂不可用:%s', result.get('error'))
|
||
except Exception as exc:
|
||
logging.warning('每日资金保存失败:%s', type(exc).__name__)
|
||
stopping.wait(15)
|
||
|
||
|
||
if __name__ == '__main__':
|
||
main()
|