INNER CODE UNIT · Python
_init_global_client
CassiopeiaCode/q2api · app.py:156
async def _init_global_client():
global GLOBAL_CLIENT
proxies = _get_proxies()
mounts = None
if proxies:
proxy_url = proxies.get("https") or proxies.get("http")
if proxy_url:
mounts = {
"https://": httpx.AsyncHTTPTransport(proxy=proxy_url),
"http://": httpx.AsyncHTTPTransport(proxy=proxy_url),
}
# Increased limits for high concurrency with streaming
# max_connections: 总连接数上限
# max_keepalive_connections: 保持活跃的连接数
# keepalive_expiry: 连接保持时间
limits = httpx.Limits(
max_keepalive_connections=200,
max_connections=200, # 提高到200以支持更高并发