From 80fe7e02f84d67b7ddb8ab527d9b21d6f433f53b Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Wed, 30 Apr 2025 13:43:01 -0500 Subject: [PATCH] Added missing _attempt_health_recovery. --- apps/proxy/ts_proxy/stream_manager.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apps/proxy/ts_proxy/stream_manager.py b/apps/proxy/ts_proxy/stream_manager.py index e9a531d8..771ffba8 100644 --- a/apps/proxy/ts_proxy/stream_manager.py +++ b/apps/proxy/ts_proxy/stream_manager.py @@ -719,6 +719,29 @@ class StreamManager: logger.error(f"Error in reconnect attempt: {e}", exc_info=True) return False + def _attempt_health_recovery(self): + """Attempt to recover stream health by switching to another stream""" + try: + logger.info(f"Attempting health recovery for channel {self.channel_id}") + + # Don't try to switch if we're already in the process of switching URLs + if self.url_switching: + logger.info("URL switching already in progress, skipping health recovery") + return + + # Try to switch to next stream + switch_result = self._try_next_stream() + if switch_result: + logger.info(f"Health recovery successful - switched to new stream for channel {self.channel_id}") + return True + else: + logger.warning(f"Health recovery failed - no alternative streams available for channel {self.channel_id}") + return False + + except Exception as e: + logger.error(f"Error in health recovery attempt: {e}", exc_info=True) + return False + def _close_connection(self): """Close HTTP connection resources""" # Close response if it exists