Spaces:
Runtime error
Runtime error
Joffrey Thomas commited on
Commit ·
8d1a432
1
Parent(s): 351cfea
change app.py
Browse files
app.py
CHANGED
|
@@ -524,9 +524,11 @@ def auto_start_recording(session):
|
|
| 524 |
|
| 525 |
# Check if we've hit max concurrent sessions - kill all if so
|
| 526 |
with _sessions_lock:
|
| 527 |
-
|
|
|
|
|
|
|
| 528 |
|
| 529 |
-
if
|
| 530 |
kill_all_sessions()
|
| 531 |
session.status_message = "error"
|
| 532 |
return get_transcription_html("Server reset due to capacity. Please click the microphone to restart.", "error", "")
|
|
@@ -630,13 +632,17 @@ def process_audio(audio, session_id):
|
|
| 630 |
"""Process incoming audio and queue for streaming."""
|
| 631 |
# Check capacity - if at or above max, kill ALL sessions to reset
|
| 632 |
with _sessions_lock:
|
| 633 |
-
|
| 634 |
-
# Check if THIS user is already active (they can continue)
|
| 635 |
is_active_user = session_id and any(s.session_id == session_id for s in _active_sessions.values())
|
| 636 |
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 640 |
kill_all_sessions()
|
| 641 |
return get_transcription_html(
|
| 642 |
"Server reset due to capacity. Please click the microphone to restart.",
|
|
|
|
| 524 |
|
| 525 |
# Check if we've hit max concurrent sessions - kill all if so
|
| 526 |
with _sessions_lock:
|
| 527 |
+
active_at_capacity = len(_active_sessions) >= MAX_CONCURRENT_SESSIONS
|
| 528 |
+
with _registry_lock:
|
| 529 |
+
registry_over = len(_session_registry) > MAX_CONCURRENT_SESSIONS
|
| 530 |
|
| 531 |
+
if active_at_capacity or registry_over:
|
| 532 |
kill_all_sessions()
|
| 533 |
session.status_message = "error"
|
| 534 |
return get_transcription_html("Server reset due to capacity. Please click the microphone to restart.", "error", "")
|
|
|
|
| 632 |
"""Process incoming audio and queue for streaming."""
|
| 633 |
# Check capacity - if at or above max, kill ALL sessions to reset
|
| 634 |
with _sessions_lock:
|
| 635 |
+
active_count = len(_active_sessions)
|
|
|
|
| 636 |
is_active_user = session_id and any(s.session_id == session_id for s in _active_sessions.values())
|
| 637 |
|
| 638 |
+
with _registry_lock:
|
| 639 |
+
registry_count = len(_session_registry)
|
| 640 |
+
|
| 641 |
+
# Kill all if:
|
| 642 |
+
# 1. Registry exceeds limit (memory safety)
|
| 643 |
+
# 2. Active sessions exceed limit
|
| 644 |
+
# 3. At active capacity AND new user trying to join
|
| 645 |
+
if registry_count > MAX_CONCURRENT_SESSIONS or active_count > MAX_CONCURRENT_SESSIONS or (active_count >= MAX_CONCURRENT_SESSIONS and not is_active_user):
|
| 646 |
kill_all_sessions()
|
| 647 |
return get_transcription_html(
|
| 648 |
"Server reset due to capacity. Please click the microphone to restart.",
|