【发布时间】:2023-03-24 05:40:01
【问题描述】:
在 python 中使用 asyncio 时,我们如何确定 read() 的最佳参数? 12 字节? 100 字节?
async with self._session.get(url, headers=headers) as response:
chunk_size = 12
result = ''
while True:
chunk = await response.content.read(chunk_size)
if not chunk:
break
elif isinstance(chunk, (bytes, bytearray)):
data = chunk.decode('utf8')
result += data
【问题讨论】:
标签: python python-asyncio aiohttp