Commit 1a278263 authored by wang.wenrong's avatar wang.wenrong

Merge branch 'wwr' into 'develop'

fix_2s_downloads

See merge request !44
parents 032a739b ad031b1b
import asyncio
import datetime
import json
import math
......@@ -73,31 +74,36 @@ async def get_scope_list_by_pid(pids, start_dt, end_dt, scope_g="2s"):
scope_list = []
starttime_wm = datetime.datetime.now()
print(f'起始时间:{starttime_wm}')
task_list = []
for scope_data in scope_url_data:
try:
async with QsClient() as qs:
url = scope_data.get("url")
wave_data = await qs.get_object(url)
[scope_list.append({"datetime": scope_data['datetime'],
"ua": wave_data['ua'][i],
"ub": wave_data['ub'][i],
"uc": wave_data['uc'][i],
"ia": wave_data['ia'][i],
"ib": wave_data['ib'][i],
"ic": wave_data['ic'][i],
"lc": wave_data['lc'][i],
"pttl": wave_data['pttl'][i]}) for i in
range(len(wave_data.get('ua')))]
# for i in range(len(wave_data['ua'])):
# a_dict = dict(zip(wave_data.keys(),
# list(zip(*wave_data.values()))[i]))
# a_dict["datetime"] = scope_data['datetime']
# scope_list.append(a_dict)
url = scope_data.get("url")
task_list.append(get_qs_datas(url))
except Exception as e:
LOGGER.error(f"scope_detail_service error message:{str(e)}")
return []
qs_dats = await asyncio.gather(*task_list)
qs_data_map = {data[0]: data[1] for data in qs_dats}
for scope_data in scope_url_data:
url = scope_data.get("url")
wave_data = qs_data_map[url]
[scope_list.append({"datetime": scope_data['datetime'],
"ua": wave_data['ua'][i],
"ub": wave_data['ub'][i],
"uc": wave_data['uc'][i],
"ia": wave_data['ia'][i],
"ib": wave_data['ib'][i],
"ic": wave_data['ic'][i],
"lc": wave_data['lc'][i],
"pttl": wave_data['pttl'][i]}) for i in
range(len(wave_data.get('ua')))]
end_time_wm = datetime.datetime.now()
print(f'结束时间:{end_time_wm}')
return scope_list
async def get_qs_datas(url):
async with QsClient() as qs:
wave_data = await qs.get_object(url)
return url, wave_data
......@@ -510,7 +510,7 @@ async def scope_detail_service(event_id):
wave_data = await qs.get_object(url)
except Exception as e:
LOGGER.error(f"scope_detail_service error message:{str(e)}")
return {}, [], [], [], [], [], [], [], []
return {}, [], [], [], []
# 录波颗粒度
scope_g = scope_data.get("scope_g")
if ctnum == 2:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment