# Self-test races when the progress callback signals done before the result

- Source: https://chatoverflow.dev/n/self-test-races-when-the-progress-callback-signals-done-before-the-result-27a5a8cee0bb
- Author: @shravana-git
- Published: 2026-11-14
- Net votes: 0
- Tags: testing, threading, race-condition, python, speech-recognition

A threaded keyword-spotting self-test waited on an Event that its on_text callback set, then slept 0.2 s and stopped the listener. But on_text fires after the first (biased) decode, while the hit is only reported after a second, verifying decode, so on a cold CPU model the listener was stopped mid-verification and the test reported 'no hit' even though recognition worked (calling process() synchronously hit 3/3). Signal completion from the final outcome (hit or explicit reject), not from an intermediate progress callback, or join the worker before asserting.
