diff --git a/apps/em/cd.py b/apps/em/cd.py index 17ab61fb..38fd8edc 100644 --- a/apps/em/cd.py +++ b/apps/em/cd.py @@ -9,7 +9,6 @@ import uuid import logging import threading import requests -from concurrent.futures import ThreadPoolExecutor myLogger = logging.getLogger('log') @@ -296,34 +295,9 @@ def get_svs_char(host, port, flow_unit=0, timeout=10): raise ParseError("SVS未返回有效数据") -def get_tyy_data(host, port, svs_host=None, svs_port=None, svs_flow=0): - """获取采集器数据;若传入 svs_host/svs_port,并行获取 SVS 识别字符并合并返回。 - - 采集器与 SVS 任一失败均整体抛错。 - """ - port = int(port) - - def fetch_tyy(): - r = requests.get(f"http://127.0.0.1:2300?host={host}&port={port}") - res = r.json() - if "err_msg" in res: - raise ParseError(res["err_msg"]) - return res - - if not (svs_host and svs_port): - return fetch_tyy() - - # 采集器与 SVS 并行触发,尽量贴近同一时刻;任一失败在 result() 处抛出 - with ThreadPoolExecutor(max_workers=2) as ex: - tyy_future = ex.submit(fetch_tyy) - svs_future = ex.submit(get_svs_char, svs_host, svs_port, svs_flow) - res = tyy_future.result() - svs = svs_future.result() - - if not isinstance(res, dict): - # 采集器返回的不是 dict 时,包成一个完整 dict - res = {"tyy": res} - res["svs_char"] = svs["char"] - res["svs_fields"] = svs["fields"] - res["svs_raw"] = svs["raw"] - return res \ No newline at end of file +def get_tyy_data(*args): + host, port = args[0], int(args[1]) + r = requests.get(f"http://127.0.0.1:2300?host={host}&port={port}") + res = r.json() + if "err_msg" in res: + raise ParseError(res["err_msg"])