فهرست منبع

Fix CPU spin loop in motion thread readline wait

Added sleep(0.01) after readline() to prevent 100% CPU usage when
readline() returns empty (timeout or bad serial state). Without this,
the inner while loop would spin continuously.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 1 هفته پیش
والد
کامیت
50df3a3ec7
1فایلهای تغییر یافته به همراه2 افزوده شده و 0 حذف شده
  1. 2 0
      modules/core/pattern_manager.py

+ 2 - 0
modules/core/pattern_manager.py

@@ -545,6 +545,8 @@ class MotionControlThread:
                         if response.lower() == "ok":
                             logger.debug("Motion thread: Command execution confirmed.")
                             return True
+                    # Small sleep to prevent CPU spin when readline() times out
+                    time.sleep(0.01)
 
             except Exception as e:
                 error_str = str(e)