From 03df5bf3b13f73ac1aa542f5496a07cf3db6fc68 Mon Sep 17 00:00:00 2001 From: ymq1 Date: Wed, 11 Jun 2025 09:09:14 +0000 Subject: [PATCH] bugfix --- appPublic/streamhttpclient.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/appPublic/streamhttpclient.py b/appPublic/streamhttpclient.py index c3689ff..24bca97 100755 --- a/appPublic/streamhttpclient.py +++ b/appPublic/streamhttpclient.py @@ -10,6 +10,23 @@ import ssl import os from appPublic.log import exception, debug +async def liner(async_gen): + remainer = '' + async for chunk in async_gen: + chunk = chunk.decode('utf-8') + d = remainer + chunk + lst = d.split('\n', 1) + if len(lst) == 2: + if lst[0]: + yield lst[0] + remainer = lst[1] + else: + remainer = lst[0] + for l in remainer.split('\n'): + if l: + await asyncio.sleep(0) + yield l + class StreamHttpClient: def __init__(self, socks5_url="socks5://127.0.0.1:1086"): home = os.path.expanduser("~")