mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-29 20:49:42 +00:00
fix(utils): validate precise_sleep spin/margin args (#4218)
* fix(utils): validate precise_sleep spin/margin args Negative spin_threshold/sleep_margin make remaining arithmetic wrong and can overshoot. Reject them early; cover the no-op path. * test: drop flaky wall-clock assertion in no-op test Per review: the 50ms wall-clock check can exceed its bound on a preempted CI worker even when precise_sleep returns immediately. The direct calls already exercise the non-positive no-op path, so the assertion is redundant. * chore(tests): remove precise_sleep test negative values --------- Co-authored-by: Bartok9 <danielrpike9@gmail.com>
This commit is contained in:
@@ -30,6 +30,10 @@ def precise_sleep(seconds: float, spin_threshold: float = 0.010, sleep_margin: f
|
||||
"""
|
||||
if seconds <= 0:
|
||||
return
|
||||
if spin_threshold < 0:
|
||||
raise ValueError(f"spin_threshold must be >= 0, got {spin_threshold}")
|
||||
if sleep_margin < 0:
|
||||
raise ValueError(f"sleep_margin must be >= 0, got {sleep_margin}")
|
||||
|
||||
system = platform.system()
|
||||
# On macOS and Windows the scheduler / sleep granularity can make
|
||||
|
||||
Reference in New Issue
Block a user