python - 并行天蓝色 blob 上传获取警告“urllib3.connectionpool 警告 - 连接池已满,正在丢弃连接”
问题描述
由于我需要将超过100000的大量文件上传到azure blob存储中,所以我编写了一个程序通过这样的多线程处理上传。
from azure.storage.blob import BlobServiceClient, BlobClient
from itertools import repeat
from concurrent.futures import ThreadPoolExecutor
import os
def upload_single_blob(blob_service_client, blob_path):
# Create a blob client using the local file name as the name for the blob
blob_client = blob_service_client.get_blob_client(container='MyContainer',
blob=blob_path)
# Upload the file
with open(blob_path, "rb") as data:
blob_client.upload_blob(data)
# make blob service client from connect str
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
# make file path list to upload
blob_path_list = os.listdir("./blob_files/")
blob_path_list = map(lambda x: "./blob_files/"+x, blob_path_list)
blob_path_list = list(blob_path_list)
# multi threading upload to blob
with ThreadPoolExecutor(max_workers=100) as executor:
executor.map(upload_single_blob, repeat(blob_service_client), blob_path_list)
但是,当我在 azure VM(操作系统是 ubuntu18.04)上运行这个程序时,我收到了很多警告。
urllib3.connectionpool WARNING --Connection pool is full, discarding connection: myblobaccount.blob.core.windows.net
我没有准确测量它,但似乎同时只有大约10个连接,即使以100个线程并行上传。
如何再增加连接数?
解决方案
推荐阅读
- python - 在python中枚举具有给定叶节点数量的有序二叉树结构
- php - LARAVEL ERRORS - 流浪者提供后的 Hashicorp/嵌入错误
- php - 利用$outputs 中的 s
- java - 使用 dropwizard 时附加自定义标头以访问日志
- python - 如何在python的数据框中添加一列,其值取决于多列
- azure-devops - 试图将组织 A 项目 A 工作项移动到组织 B 项目 B
- excel - Excel VBA:满足条件时将列复制到另一个工作表
- javascript - 如何在 Javascript Laravel 上编写资产 URL
- sql - 如何在 Oracle 中使用 LOOP 引用动态变量
- pytorch - 张量板不一致的折线图颜色