Fix pause CPU consumption (#81519)

* Sleep for the DEFAULT_INTERNAL_POLL_INTERVAL between polling for user input

Fixes #81516
This commit is contained in:
Sloane Hertel
2023-08-22 15:03:22 -04:00
committed by GitHub
parent 3e9d374fda
commit 194f829b0f
2 changed files with 4 additions and 0 deletions
@@ -0,0 +1,2 @@
bugfixes:
- Prompting - add a short sleep between polling for user input to reduce CPU consumption (https://github.com/ansible/ansible/issues/81516).
+2
View File
@@ -708,6 +708,8 @@ class Display(metaclass=Singleton):
os.set_blocking(self._stdin_fd, False)
while key_pressed is None and (seconds is None or (time.time() - start < seconds)):
key_pressed = self._stdin.read(1)
# throttle to prevent excess CPU consumption
time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)
finally:
os.set_blocking(self._stdin_fd, True)
if key_pressed is None: