fix(busy_wait): fix busy_wait implementation for Windows platforms and removing erronous TODO (#1695)

This commit is contained in:
Caroline Pascal
2025-08-08 10:46:14 +02:00
committed by GitHub
parent ce3b9f627e
commit 11e6bd762a

View File

@@ -17,10 +17,9 @@ import time
def busy_wait(seconds):
if platform.system() == "Darwin":
# On Mac, `time.sleep` is not accurate and we need to use this while loop trick,
if platform.system() == "Darwin" or platform.system() == "Windows":
# On Mac and Windows, `time.sleep` is not accurate and we need to use this while loop trick,
# but it consumes CPU cycles.
# TODO(rcadene): find an alternative: from python 11, time.sleep is precise
end_time = time.perf_counter() + seconds
while time.perf_counter() < end_time:
pass