kshitij
72c63aa586
fix(stt): close idle-unload races — strong model ref, single long-lived watcher
...
Review pass on the idle-unload feature found two material concurrency
bugs; both fixed here with a regression guard:
1. Unload-vs-use null deref (HIGH): _transcribe_local re-read the
module global _local_model at the transcribe call site. An idle
unload firing between the model load and transcribe() evaluated
None.transcribe → AttributeError → user-visible 'Local
transcription failed'. The window was real: the idle timer was only
touched AFTER a successful transcription, so a voice note arriving
exactly as the timeout expired raced the watcher directly.
Fix: bind a strong local reference under the model lock and use it
for the whole transcription (the watcher can null the global at any
time; this in-flight call keeps its instance — the generator holds
self, so no use-after-free). Also touch the idle timer at the START
of transcription so a long in-flight transcribe can't be counted as
idle time. The CUDA-fallback retry path gets the same treatment
(locked global write, local ref use).
2. Watcher replacement race + response-path join (MEDIUM/HIGH): the
old design stopped and re-started the watcher after EVERY
transcription with an unlocked set/join(5)/clear/start sequence on
shared globals. Two concurrent voice messages could interleave to
leave TWO live watchers (one with a stale, shorter timeout — a
raised unload_after_idle_seconds could still unload on the old
value), and the join(timeout=5) sat on the user-visible response
path (a watcher blocked on _local_model_lock during a concurrent
multi-second model load stalls the reply up to 5s).
Fix: single long-lived watcher under a management lock — started
only when none is alive (per-transcription cost: one lock + one
is_alive check), re-reads the configured timeout from config every
cycle (config edits now apply within one 30s interval, without
waiting for the next voice message — previously undocumented), and
stands down without unloading when the timeout is set to 0
mid-idle.
Tests: 17 now — idempotent start (same thread, no churn), config
re-read + stand-down-when-disabled, and the race guard
(unload firing mid-transcription must not fail the in-flight call).
The race guard is mutation-verified: reverting the fix (re-reading
the global at the call site) makes it fail with the exact NoneType
error; the fixed code passes.
2026-08-07 19:26:12 +05:30
..
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 21:17:49 +05:30
2026-07-29 13:39:40 -07:00
2026-07-12 22:43:57 -07:00
2026-07-29 11:19:24 -07:00
2026-07-13 04:31:55 -07:00
2026-08-04 12:43:38 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 14:02:08 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 13:47:29 +05:30
2026-08-02 15:11:21 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:11:50 -07:00
2026-06-29 01:26:24 -07:00
2026-08-02 00:11:50 -07:00
2026-07-03 03:27:47 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-01 05:23:17 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-06-28 14:25:10 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 11:18:41 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-07-29 10:06:27 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 12:19:37 -07:00
2026-07-29 12:19:37 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 13:42:03 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-07-31 17:43:37 -04:00
2026-07-29 13:39:40 -07:00
2026-08-03 00:25:20 +05:30
2026-07-29 13:39:40 -07:00
2026-08-06 23:14:55 -07:00
2026-08-06 23:14:55 -07:00
2026-07-31 22:33:00 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-05 14:00:25 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-22 12:13:01 -05:00
2026-07-09 15:38:32 +05:30
2026-08-02 00:11:50 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 16:44:31 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:36:03 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-01 10:52:34 -07:00
2026-08-02 00:36:03 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 00:25:20 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 21:30:53 -07:00
2026-07-29 13:39:40 -07:00
2026-08-06 05:31:17 +05:30
2026-08-02 15:09:33 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-06 01:55:58 -07:00
2026-08-03 22:53:32 +05:30
2026-07-29 13:39:40 -07:00
2026-08-01 14:31:51 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:09:33 -07:00
2026-08-04 14:34:24 +05:30
2026-07-29 13:39:40 -07:00
2026-07-31 10:17:55 -04:00
2026-08-06 19:35:47 -06:00
2026-08-01 15:41:21 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 23:11:56 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:11:50 -07:00
2026-07-29 13:39:40 -07:00
2026-07-24 17:10:39 -07:00
2026-08-03 22:53:32 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 17:43:37 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-30 07:18:08 -05:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 14:09:46 +05:30
2026-08-07 13:28:43 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:36:03 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 15:12:28 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 10:17:55 -04:00
2026-07-29 13:39:40 -07:00
2026-07-17 20:55:24 +00:00
2026-07-29 13:39:40 -07:00
2026-07-17 20:55:24 +00:00
2026-07-29 13:39:40 -07:00
2026-07-31 21:21:10 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 14:31:24 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-30 03:35:35 +05:30
2026-07-29 13:39:40 -07:00
2026-08-03 14:24:37 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-21 12:43:00 -07:00
2026-07-18 18:49:56 -04:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-17 20:55:24 +00:00
2026-07-29 13:39:40 -07:00
2026-07-05 21:48:36 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 14:24:37 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 15:13:21 -07:00
2026-07-24 15:47:12 -07:00
2026-07-07 15:16:00 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-01 11:35:59 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-06 19:35:47 -06:00
2026-08-01 10:47:20 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:09:53 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:51:43 -07:00
2026-08-04 14:34:24 +05:30
2026-08-02 15:12:02 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 17:01:23 +05:30
2026-08-02 15:11:02 -07:00
2026-08-05 22:02:42 -07:00
2026-07-29 13:39:40 -07:00
2026-08-06 19:35:47 -06:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 20:11:20 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:13:24 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:13:04 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-06 05:31:17 +05:30
2026-08-02 15:42:44 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 17:50:58 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 07:30:30 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 07:30:30 -07:00
2026-08-02 15:12:43 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 21:31:10 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 22:33:11 -07:00
2026-08-02 20:12:37 -07:00
2026-07-29 13:39:40 -07:00
2026-07-30 22:31:42 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-31 07:30:30 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-26 19:30:02 -07:00
2026-08-03 13:47:29 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 21:54:10 +05:30
2026-08-07 19:26:04 +05:30
2026-07-29 13:39:40 -07:00
2026-08-07 19:26:12 +05:30
2026-07-29 13:39:40 -07:00
2026-08-03 14:30:05 +05:30
2026-08-06 09:40:27 -07:00
2026-07-24 11:45:57 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:10:13 -07:00
2026-08-01 15:03:42 +05:30
2026-07-29 13:39:40 -07:00
2026-08-01 15:41:21 -07:00
2026-08-02 15:08:35 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 19:48:37 -07:00
2026-08-01 15:38:57 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 00:11:50 -07:00
2026-08-03 13:47:29 +05:30
2026-08-02 15:52:14 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-21 05:27:23 -07:00
2026-08-04 12:43:38 -04:00
2026-07-29 13:39:40 -07:00
2026-07-14 02:59:39 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 11:57:37 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 11:55:48 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-28 11:53:36 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-03 10:25:15 +05:30
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 21:30:53 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 18:50:39 +05:30
2026-08-07 14:38:02 +05:30
2026-07-29 13:39:40 -07:00
2026-07-28 18:12:26 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-07 14:38:02 +05:30
2026-07-28 11:57:37 -07:00
2026-08-05 10:06:49 -06:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 23:16:18 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 15:12:23 -07:00
2026-07-29 13:39:40 -07:00
2026-08-02 09:59:52 -07:00
2026-07-29 13:39:40 -07:00
2026-07-29 14:12:25 -07:00
2026-07-29 13:39:40 -07:00