This commit is contained in:
Nirvana
2026-01-31 15:18:26 +01:00
parent 6b429553cc
commit 8f5d99b476
2 changed files with 11 additions and 15 deletions
@@ -1,5 +1,6 @@
# streaming_providers/base/network/http_manager.py
import json
import logging
import time
from typing import Any, Dict, Optional
@@ -10,6 +11,10 @@ from urllib3.util.retry import Retry
from ..models.proxy_models import ProxyConfig, RequestConfig
from ..utils.logger import logger
# Suppress urllib3 connection pool logging to prevent "Closing connection" messages
# This affects all providers using HTTPManager
logging.getLogger("urllib3.connectionpool").setLevel(logging.WARNING)
class HTTPManager:
"""
@@ -353,4 +358,4 @@ class HTTPManagerFactory:
Configured HTTPManager instance
"""
proxy_config = ProxyConfig.from_url(proxy_url)
return HTTPManagerFactory.create_for_provider(provider_name, proxy_config, **kwargs)
return HTTPManagerFactory.create_for_provider(provider_name, proxy_config, **kwargs)
@@ -520,26 +520,17 @@ class BHTelecomProvider(StreamingProvider):
"""
Close HTTP manager and cleanup resources
Call this when you're done with the provider to avoid
connection cleanup messages appearing in output.
Call this when you're done with the provider to ensure
proper cleanup of HTTP sessions and connections.
"""
if hasattr(self, 'http_manager') and self.http_manager:
self.http_manager.close()
def __enter__(self):
"""Context manager entry"""
"""Context manager entry - enables 'with' statement usage"""
return self
def __exit__(self, exc_type, exc_val, exc_tb):
"""Context manager exit - ensures cleanup"""
"""Context manager exit - ensures cleanup on context exit"""
self.close()
def __del__(self):
"""Destructor - silent cleanup"""
try:
if hasattr(self, 'http_manager') and self.http_manager:
# Close quietly without logging
if hasattr(self.http_manager, '_session') and self.http_manager._session:
self.http_manager._session.close()
except:
pass # Silent cleanup on deletion
return False # Don't suppress exceptions