From 4c1b25df33a306a836a25351d9c4da2440f1363f Mon Sep 17 00:00:00 2001 From: Thomas Rachel Date: Wed, 17 Jun 2026 13:33:54 +0200 Subject: [PATCH] Derive the sleep time from the Tk settings The Tk main loop defines its sleep time via the parameter "getbusywaitinterval". Adjust our waiting time to that value. --- async_tkinter_loop/async_tkinter_loop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/async_tkinter_loop/async_tkinter_loop.py b/async_tkinter_loop/async_tkinter_loop.py index 9547629..b025ec3 100644 --- a/async_tkinter_loop/async_tkinter_loop.py +++ b/async_tkinter_loop/async_tkinter_loop.py @@ -26,7 +26,8 @@ async def main_loop(root: tk.Tk) -> None: except tk.TclError: break - await asyncio.sleep(0.01) + interval_ms = tk._tkinter.getbusywaitinterval() + await asyncio.sleep(interval_ms / 1000) def get_event_loop() -> asyncio.AbstractEventLoop: