Fix race condition: set _running before starting reader thread

The reader thread loop checks self._running but it was being set to
True after _start_satdump() returned, which is after the thread
already started. The thread would see _running=False and exit
immediately without reading any SatDump output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mitch Ross
2026-02-07 15:28:07 -05:00
parent f9786aa75a
commit 03c5d33eb7

View File

@@ -252,8 +252,8 @@ class WeatherSatDecoder:
self._capture_phase = 'tuning' self._capture_phase = 'tuning'
try: try:
self._start_satdump(sat_info, device_index, gain, sample_rate, bias_t)
self._running = True self._running = True
self._start_satdump(sat_info, device_index, gain, sample_rate, bias_t)
logger.info( logger.info(
f"Weather satellite capture started: {satellite} " f"Weather satellite capture started: {satellite} "
@@ -272,6 +272,7 @@ class WeatherSatDecoder:
return True return True
except Exception as e: except Exception as e:
self._running = False
logger.error(f"Failed to start weather satellite capture: {e}") logger.error(f"Failed to start weather satellite capture: {e}")
self._emit_progress(CaptureProgress( self._emit_progress(CaptureProgress(
status='error', status='error',