[WIP] GUI: Reduce CPU usage by adding sleep intervals to UI wait loops

Fix issue where the GUI main thread was consuming excessive CPU while
waiting for background tasks to complete.
By adding a configurable sleep interval between UI updates,
CPU usage is significantly reduced while maintaining responsiveness.

- Add thread_sleep_interval constant to global Constants class
- Implement wait_for_thread utility function in gui_support
- Update all wxPython event loops to use the new helper
- Test shows approximately 60% CPU usage reduction during waits
This commit is contained in:
Gonen
2025-04-03 23:17:15 +03:00
parent 95bf012438
commit 4ce91cad3d
13 changed files with 55 additions and 55 deletions

View File

@@ -155,6 +155,8 @@ class Constants:
self.unpack_thread = None # Determine if unpack thread finished (threading.Thread)
self.update_stage: int = 0 # Determine update stage (see gui_support.py)
self.log_filepath: Path = None # Path to log file
self.thread_sleep_interval: float = 0.1 # Sleep interval between UI updates (seconds) - reduce refresh-rate to reduce CPU-usage
self.thread_nap_interval: float = 0.01 # Short Sleep interval between UI updates (seconds) - for faster UI updates of the progress bar
self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL)