From 9f7086628c58392b7bdc45f9f0994bfbd64b99c6 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Sat, 13 Jan 2024 16:54:56 +0200 Subject: Fixing 100% CPU usage on constant stdin polling by sleeping a bit. --- tui/tui.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tui') diff --git a/tui/tui.py b/tui/tui.py index d8c6a5d..1262825 100644 --- a/tui/tui.py +++ b/tui/tui.py @@ -1,4 +1,5 @@ import termios, fcntl, sys, os +from time import sleep from tui.static import Action, ActionKeys, ActionEscKeys, Colors, TileTypes class Tui(): @@ -64,6 +65,8 @@ class Tui(): escape = 0 while True: try: + # Ehkä riittää jos näppäimiä luetaan 200x sekunnissa + sleep(0.005) c = sys.stdin.read(1) except: continue -- cgit v1.2.3