diff --git a/appPublic/myTE.py b/appPublic/myTE.py index bba3222..302e50d 100755 --- a/appPublic/myTE.py +++ b/appPublic/myTE.py @@ -17,7 +17,7 @@ def string_template_render(tmplstr, data): return te.renders(tmplstr, data) class MyTemplateEngine: - def __init__(self,pathList,file_coding='utf-8',out_coding='utf-8', env={}): + def __init__(self,pathList,file_coding='utf-8',out_coding='utf-8', env={}, enable_async=False): self.file_coding = file_coding self.out_coding = out_coding loader = FileSystemLoader(pathList, encoding=self.file_coding) diff --git a/appPublic/streamhttpclient.py b/appPublic/streamhttpclient.py index 4b77dc0..2963dd3 100755 --- a/appPublic/streamhttpclient.py +++ b/appPublic/streamhttpclient.py @@ -155,9 +155,16 @@ class StreamHttpClient: req_args["data"] = data async with session.request(method, url, **req_args) as response: - response.raise_for_status() - async for chunk in response.content.iter_chunked(chunk_size): - yield chunk + try: + response.raise_for_status() + async for chunk in response.content.iter_chunked(chunk_size): + yield chunk + except aiohttp.ClientResponseError as e: + debug(f'❌ HTTP {response.status}: {response.reason}, {response.text()}" + raise e + except Exception as e: + debug(f'❌ HTTP {response.status}: {response.reason}" + raise e if __name__ == '__main__': import asyncio