feat: connection pooling via urllib3 + batch OG fetching
Replace per-request SOCKS5+TLS handshakes with urllib3 SOCKSProxyManager connection pool (20 pools, 4 conns/host). Batch _fetch_og calls via ThreadPoolExecutor to parallelize OG tag enrichment in alert polling. Cache flaskpaste SSL context at module level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,14 +34,23 @@ def _has_client_cert() -> bool:
|
||||
return (_CERT_DIR / "derp.crt").exists() and (_CERT_DIR / "derp.key").exists()
|
||||
|
||||
|
||||
_cached_ssl_ctx: ssl.SSLContext | None = None
|
||||
|
||||
|
||||
def _ssl_context() -> ssl.SSLContext:
|
||||
"""Build SSL context, loading client cert for mTLS if available."""
|
||||
ctx = ssl.create_default_context()
|
||||
cert_path = _CERT_DIR / "derp.crt"
|
||||
key_path = _CERT_DIR / "derp.key"
|
||||
if cert_path.exists() and key_path.exists():
|
||||
ctx.load_cert_chain(str(cert_path), str(key_path))
|
||||
return ctx
|
||||
"""Build SSL context, loading client cert for mTLS if available.
|
||||
|
||||
Cached at module level -- cert files are static at runtime.
|
||||
"""
|
||||
global _cached_ssl_ctx
|
||||
if _cached_ssl_ctx is None:
|
||||
ctx = ssl.create_default_context()
|
||||
cert_path = _CERT_DIR / "derp.crt"
|
||||
key_path = _CERT_DIR / "derp.key"
|
||||
if cert_path.exists() and key_path.exists():
|
||||
ctx.load_cert_chain(str(cert_path), str(key_path))
|
||||
_cached_ssl_ctx = ctx
|
||||
return _cached_ssl_ctx
|
||||
|
||||
|
||||
def _solve_pow(nonce: str, difficulty: int) -> int:
|
||||
|
||||
Reference in New Issue
Block a user