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("~")