diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-13 16:54:56 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-13 16:54:56 +0200 |
commit | 9f7086628c58392b7bdc45f9f0994bfbd64b99c6 (patch) | |
tree | ae8d4157fc13e6144803ab637e4f965d882492c6 | |
parent | 39b556941b386687c7819df458772a32a96b44e4 (diff) |
Fixing 100% CPU usage on constant stdin polling by sleeping a bit.
-rw-r--r-- | tui/tui.py | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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 |