first commit
This commit is contained in:
parent
c5edea9522
commit
607fa53553
|
|
@ -137,10 +137,13 @@ class ApiRequest:
|
||||||
try:
|
try:
|
||||||
if chunk.startswith("data: "):
|
if chunk.startswith("data: "):
|
||||||
data = json.loads(chunk[6:-2])
|
data = json.loads(chunk[6:-2])
|
||||||
|
pprint(data,depth=1)
|
||||||
elif chunk.startswith(":"): # skip sse comment line
|
elif chunk.startswith(":"): # skip sse comment line
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
data = json.loads(chunk)
|
data = json.loads(chunk)
|
||||||
|
pprint(data,depth=1)
|
||||||
|
#print(f"{data}")
|
||||||
yield data
|
yield data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。"
|
msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。"
|
||||||
|
|
@ -173,17 +176,21 @@ class ApiRequest:
|
||||||
try:
|
try:
|
||||||
if chunk.startswith("data: "):
|
if chunk.startswith("data: "):
|
||||||
data = json.loads(chunk[6:-2])
|
data = json.loads(chunk[6:-2])
|
||||||
|
print("ret_sync, data = json.loads(chunk[6:-2])")
|
||||||
|
pprint(data,depth=1)
|
||||||
elif chunk.startswith(":"): # skip sse comment line
|
elif chunk.startswith(":"): # skip sse comment line
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
# print(f"{chunk}")
|
||||||
data = json.loads(chunk)
|
data = json.loads(chunk)
|
||||||
|
print("ret_sync, data = json.loads(chunk)")
|
||||||
|
pprint(data,depth=1)
|
||||||
yield data
|
yield data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。"
|
msg = f"接口返回json错误: ‘{chunk}’。错误信息是:{e}。"
|
||||||
logger.error(f'{e.__class__.__name__}: {msg}',
|
logger.error(f'{e.__class__.__name__}: {msg}',
|
||||||
exc_info=e if log_verbose else None)
|
exc_info=e if log_verbose else None)
|
||||||
else:
|
else:
|
||||||
# print(chunk, end="", flush=True)
|
|
||||||
yield chunk
|
yield chunk
|
||||||
except httpx.ConnectError as e:
|
except httpx.ConnectError as e:
|
||||||
msg = f"无法连接API服务器,请确认 ‘api.py’ 已正常启动。({e})"
|
msg = f"无法连接API服务器,请确认 ‘api.py’ 已正常启动。({e})"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue