Check for any state to detmine if channel is running.

This commit is contained in:
SergeantPanda 2025-07-01 10:57:07 -05:00
parent 2b97a958cd
commit 8e2c6c7780
2 changed files with 3 additions and 11 deletions

View file

@ -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:

View file

@ -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()