mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-26 11:34:32 +00:00
This update addresses issues related to geventpool database connection leaks by consistently invoking `close_old_connections()` in `finally` blocks within the backup scheduler, plugin repository refresh, and core notification synchronization processes. These changes ensure that idle connections are properly released, preventing resource exhaustion. HLS proxy server has been disabled (hasn't been used). Additionally, the proxy server cleanup logic has been enhanced to safely handle the absence of proxy instances. Tests have been updated to validate these improvements and ensure stability in high-load scenarios.
23 lines
932 B
Python
23 lines
932 B
Python
from django.db.models.signals import pre_delete
|
|
from django.dispatch import receiver
|
|
from django.apps import apps
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
@receiver(pre_delete)
|
|
def cleanup_proxy_servers(sender, **kwargs):
|
|
"""Clean up proxy servers when Django shuts down"""
|
|
try:
|
|
proxy_app = apps.get_app_config('proxy')
|
|
hls_proxy = getattr(proxy_app, 'hls_proxy', None)
|
|
if hls_proxy is not None:
|
|
for channel_id in list(hls_proxy.stream_managers.keys()):
|
|
hls_proxy.stop_channel(channel_id)
|
|
live_proxy = getattr(proxy_app, 'live_proxy', None)
|
|
if live_proxy is not None:
|
|
for channel_id in list(live_proxy.stream_managers.keys()):
|
|
live_proxy.stop_channel(channel_id)
|
|
logger.info("Proxy servers cleaned up successfully")
|
|
except Exception as e:
|
|
logger.error(f"Error during proxy server cleanup: {e}")
|