Scx9n revives#3660
Conversation
…of audio bytes on some 3rd devices
Co-authored-by: aider (anthropic/claude-opus-4-5-20251101) <aider@aider.chat>
There was a problem hiding this comment.
Code Review
This pull request updates the websocket inactivity timeout logic. It changes the trigger for timeout from 'last audio received' to 'last activity of any kind', which is a good improvement to prevent sessions from closing while non-audio data is being transmitted. The timeout duration is also increased. My review includes one high-severity comment regarding code maintainability in the send_heartbeat function to ensure clarity and prevent future bugs.
|
|
||
| # Inactivity timeout | ||
| if last_audio_received_time and time.time() - last_audio_received_time > inactivity_timeout_seconds: | ||
| if last_activity_time and time.time() - last_activity_time > inactivity_timeout_seconds: |
There was a problem hiding this comment.
While this change is functionally correct, there's a maintainability issue in the send_heartbeat function. The variable last_activity_time is now used, but it's not declared as nonlocal at the top of the function, which is inconsistent with other variables from the enclosing scope. Additionally, last_audio_received_time is still declared nonlocal but is no longer used within this function.
To improve clarity and prevent potential bugs in future modifications, please update the nonlocal declarations as follows:
# In send_heartbeat() function
...
nonlocal websocket_close_code
nonlocal started_at
nonlocal last_activity_time # Add this
# nonlocal last_audio_received_time <- And remove this line
...* increase the stt inactivity timeout threshold due to the instability of audio bytes on some 3rd devices * Use last_activity_time to track session inactivity timeout Co-authored-by: aider (anthropic/claude-opus-4-5-20251101) <aider@aider.chat> --------- Co-authored-by: aider (anthropic/claude-opus-4-5-20251101) <aider@aider.chat>
No description provided.