From 8e2c6c7780215b631b2d40d0dec489701a84f556 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 1 Jul 2025 10:57:07 -0500 Subject: [PATCH] Check for any state to detmine if channel is running. --- apps/proxy/ts_proxy/server.py | 2 +- apps/proxy/ts_proxy/views.py | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/proxy/ts_proxy/server.py b/apps/proxy/ts_proxy/server.py index 4699091a..da5daaa7 100644 --- a/apps/proxy/ts_proxy/server.py +++ b/apps/proxy/ts_proxy/server.py @@ -708,7 +708,7 @@ class ProxyServer: elif state in [ChannelState.STOPPING, ChannelState.STOPPED, ChannelState.ERROR]: # These states indicate the channel should be reinitialized logger.info(f"Channel {channel_id} exists but in terminal state: {state}") - return False + return True else: # Unknown or initializing state, check how long it's been in this state if b'state_changed_at' in metadata: diff --git a/apps/proxy/ts_proxy/views.py b/apps/proxy/ts_proxy/views.py index b9ba3e65..7192937d 100644 --- a/apps/proxy/ts_proxy/views.py +++ b/apps/proxy/ts_proxy/views.py @@ -83,15 +83,7 @@ def stream_ts(request, channel_id): if state_field in metadata: channel_state = metadata[state_field].decode("utf-8") - # IMPROVED: Check for *any* state that indicates initialization is in progress - active_states = [ - ChannelState.INITIALIZING, - ChannelState.CONNECTING, - ChannelState.WAITING_FOR_CLIENTS, - ChannelState.ACTIVE, - ChannelState.BUFFERING, - ] - if channel_state in active_states: + if channel_state: # Channel is being initialized or already active - no need for reinitialization needs_initialization = False logger.debug( @@ -132,7 +124,7 @@ def stream_ts(request, channel_id): logger.warning( f"[{client_id}] Channel {channel_id} in state {channel_state}, forcing cleanup" ) - proxy_server.stop_channel(channel_id) + ChannelService.stop_channel(channel_id) # Use max retry attempts and connection timeout from config max_retries = ConfigHelper.max_retries()