【发布时间】:2019-09-20 14:58:00
【问题描述】:
我正在使用 aiobotocore 创建客户端:
import botocore
import aiobotocore
s3_session = aiobotocore.get_session(loop=loop)
client = s3_session.create_client(
's3',
config=botocore.client.Config(connect_timeout=10, read_timeout=10, retries={'max_attempts': 0}),
endpoint_url=endpoint_url,
)
后来我有了一个读取 8k 块的异步函数:
async def aio_read(bucket, key, range_header):
s3_object = await self.client.get_object(Bucket=bucket, Key=key, Range=range_header)
s3_iostream = s3_object['Body']
b = None
body_data = b''
while b != b'':
b = await s3_iostream.read(8192)
body_data += b
print('{}> len(b) / len(body_data) = {}/{}'.format(uuid, len(b), len(body_data)))
我正在测试的下载大小为 1MB,以 8k 块读取。当我并行运行 100 个进程时,我通常会遇到一些问题,并且通过上面的 print 语句,我可以看到 aio_read 函数之一在读取文件的过程中停止。
正文读取操作似乎超时,然后无限期挂起。
如果发生读取超时,是否有办法从 aiobotocore 中获取异常?
【问题讨论】:
标签: boto3 python-asyncio botocore