File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import aiohttp
1717import certifi
1818
19- from dashscope .common .constants import (
20- DEFAULT_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS ,
21- )
2219from dashscope .common .logging import logger
2320
2421_shared_ssl_context : Optional [ssl .SSLContext ] = None
@@ -41,8 +38,7 @@ async def get_shared_aio_session() -> aiohttp.ClientSession:
4138
4239 The session is lazily created on first use and reused for all
4340 subsequent calls on the same event loop. Connection pooling (keep-alive)
44- is handled by the underlying TCPConnector with idle timeout configured
45- to close stale connections.
41+ is handled by the underlying TCPConnector.
4642 """
4743 loop = asyncio .get_running_loop ()
4844
@@ -51,10 +47,7 @@ async def get_shared_aio_session() -> aiohttp.ClientSession:
5147 if session is not None and not session .closed :
5248 return session
5349
54- connector = aiohttp .TCPConnector (
55- ssl = get_ssl_context (),
56- keepalive_timeout = DEFAULT_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS ,
57- )
50+ connector = aiohttp .TCPConnector (ssl = get_ssl_context ())
5851 session = aiohttp .ClientSession (connector = connector , trust_env = True )
5952
6053 _aio_sessions [loop ] = session
Original file line number Diff line number Diff line change 88
99import aiohttp
1010import requests
11- from requests .adapters import HTTPAdapter
1211
1312from dashscope .api_entities .aio_session import (
1413 get_shared_aio_session ,
@@ -40,21 +39,13 @@ def _get_shared_sync_session() -> requests.Session:
4039 """Return a shared requests.Session for connection pooling.
4140
4241 The session is created lazily and reused for the process lifetime;
43- it is never closed explicitly. Connection pool is configured with
44- pool size limits to control concurrent connections.
42+ it is never closed explicitly.
4543 """
4644 global _shared_sync_session
4745 if _shared_sync_session is None :
4846 with _shared_sync_session_lock :
4947 if _shared_sync_session is None :
5048 _shared_sync_session = requests .Session ()
51- # Configure connection pool size
52- adapter = HTTPAdapter (
53- pool_connections = 10 ,
54- pool_maxsize = 10 ,
55- )
56- _shared_sync_session .mount ("http://" , adapter )
57- _shared_sync_session .mount ("https://" , adapter )
5849 return _shared_sync_session
5950
6051
Original file line number Diff line number Diff line change 1717 "api_key" ,
1818)
1919
20- DEFAULT_REQUEST_TIMEOUT_SECONDS = 120
21- DEFAULT_CONNECTION_POOL_IDLE_TIMEOUT_SECONDS = 120
20+ DEFAULT_REQUEST_TIMEOUT_SECONDS = 300
2221REQUEST_TIMEOUT_KEYWORD = "request_timeout"
2322SERVICE_API_PATH = "services"
2423DASHSCOPE_LOGGING_LEVEL_ENV = "DASHSCOPE_LOGGING_LEVEL"
You can’t perform that action at this time.
0 commit comments