@@ -32,7 +32,7 @@ class CosConfig(object):
3232 """config类,保存用户相关信息"""
3333 def __init__ (self , Appid = None , Region = None , SecretId = None , SecretKey = None , Token = None , Scheme = None , Timeout = None ,
3434 Access_id = None , Access_key = None , Secret_id = None , Secret_key = None , Endpoint = None , IP = None , Port = None ,
35- Anonymous = None , UA = None , Proxies = None , Domain = None , ServiceDomain = None ):
35+ Anonymous = None , UA = None , Proxies = None , Domain = None , ServiceDomain = None , PoolConnections = 10 , PoolMaxSize = 10 ):
3636 """初始化,保存用户的信息
3737
3838 :param Appid(string): 用户APPID.
@@ -54,6 +54,8 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
5454 :param Proxies(dict): 使用代理来访问COS
5555 :param Domain(string): 使用自定义的域名来访问COS
5656 :param ServiceDomain(string): 使用自定义的域名来访问cos service
57+ :param PoolConnections(int): 连接池个数
58+ :param PoolMaxSize(int): 连接池中最大连接数
5759 """
5860 self ._appid = to_unicode (Appid )
5961 self ._token = to_unicode (Token )
@@ -67,6 +69,8 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
6769 self ._proxies = Proxies
6870 self ._domain = Domain
6971 self ._service_domain = ServiceDomain
72+ self ._pool_connections = PoolConnections
73+ self ._pool_maxsize = PoolMaxSize
7074
7175 if self ._domain is None :
7276 self ._endpoint = format_endpoint (Endpoint , Region )
@@ -176,6 +180,8 @@ def __init__(self, conf, retry=1, session=None):
176180 self ._retry = retry # 重试的次数,分片上传时可适当增大
177181 if session is None :
178182 self ._session = requests .session ()
183+ self ._session .mount ('http://' , requests .adapters .HTTPAdapter (pool_connections = self ._conf ._pool_connections , pool_maxsize = self ._conf ._pool_maxsize ))
184+ self ._session .mount ('https://' , requests .adapters .HTTPAdapter (pool_connections = self ._conf ._pool_connections , pool_maxsize = self ._conf ._pool_maxsize ))
179185 else :
180186 self ._session = session
181187
0 commit comments