def upload_blocks(bucket, chunk_size, max_threads, lines):
session = botocore.session.get_session()
client = session.create_client('s3')
start = time.perf_counter()
futures = []
with ThreadPoolExecutor(max_workers=max_threads) as executor:
# Start the load operations and mark each future with its URL
for line in lines:
raw_block, key = load_json_block(line)
futures.append(executor.submit(client.put_object,Bucket=bucket,
Key=key,
Body=raw_block,
ContentEncoding='UTF-8',
ContentType='application/json'))
end = time.perf_counter()
done, pending = concurrent.futures.wait(futures)
complete = time.perf_counter()
rate = 1 / ((complete - start) / len(done))
return len(done), int(rate)
评论列表
文章目录