mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-23 01:22:17 +02:00
Reformat
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user