Desmond-Dong commited on
Commit
477aeb2
·
1 Parent(s): 3032377

fix: 优化退出机制,减少shutdown超时

Browse files

- movement_manager: thread join timeout 2.0s -> 0.5s,跳过reset to neutral
- voice_assistant: audio thread join timeout 3.0s -> 1.0s
- camera_server: capture thread join timeout 2.0s -> 0.5s

reachy_mini_ha_voice/camera_server.py CHANGED
@@ -146,7 +146,7 @@ class MJPEGCameraServer:
146
  self._running = False
147
 
148
  if self._capture_thread:
149
- self._capture_thread.join(timeout=2.0)
150
  self._capture_thread = None
151
 
152
  if self._server:
 
146
  self._running = False
147
 
148
  if self._capture_thread:
149
+ self._capture_thread.join(timeout=0.5)
150
  self._capture_thread = None
151
 
152
  if self._server:
reachy_mini_ha_voice/movement_manager.py CHANGED
@@ -973,14 +973,13 @@ class MovementManager:
973
  # Signal stop
974
  self._stop_event.set()
975
 
976
- # Wait for thread
977
- self._thread.join(timeout=2.0)
978
  if self._thread.is_alive():
979
  logger.warning("Movement manager thread did not stop in time")
980
 
981
- # Reset robot to neutral
982
- self._reset_to_neutral_blocking()
983
-
984
  logger.info("Movement manager stopped")
985
 
986
  def _reset_to_neutral_blocking(self) -> None:
@@ -994,7 +993,7 @@ class MovementManager:
994
  head=neutral_pose,
995
  antennas=[0.0, 0.0],
996
  body_yaw=0.0,
997
- duration=1.0,
998
  )
999
  logger.info("Robot reset to neutral position")
1000
  except Exception as e:
 
973
  # Signal stop
974
  self._stop_event.set()
975
 
976
+ # Wait for thread with shorter timeout
977
+ self._thread.join(timeout=0.5)
978
  if self._thread.is_alive():
979
  logger.warning("Movement manager thread did not stop in time")
980
 
981
+ # Skip reset to neutral - let the app manager handle it
982
+ # This speeds up shutdown significantly
 
983
  logger.info("Movement manager stopped")
984
 
985
  def _reset_to_neutral_blocking(self) -> None:
 
993
  head=neutral_pose,
994
  antennas=[0.0, 0.0],
995
  body_yaw=0.0,
996
+ duration=0.3, # Faster reset
997
  )
998
  logger.info("Robot reset to neutral position")
999
  except Exception as e:
reachy_mini_ha_voice/voice_assistant.py CHANGED
@@ -355,7 +355,7 @@ class VoiceAssistantService:
355
 
356
  # 3. Wait for audio thread to finish
357
  if self._audio_thread:
358
- self._audio_thread.join(timeout=3.0)
359
  if self._audio_thread.is_alive():
360
  _LOGGER.warning("Audio thread did not stop in time")
361
 
 
355
 
356
  # 3. Wait for audio thread to finish
357
  if self._audio_thread:
358
+ self._audio_thread.join(timeout=1.0)
359
  if self._audio_thread.is_alive():
360
  _LOGGER.warning("Audio thread did not stop in time")
361