From 0a8bb228d568b86da558ee2d9cdcdebcdcf81a75 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 6 Sep 2024 17:38:31 +0200 Subject: [PATCH] frontends (tools/aio): Fix excessive use of CPU: Use a short delay instead of `loop.call_soonloop.call_soon` when work as been done, as this was resulting in an excessive use of CPU. --- libervia/frontends/tools/aio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libervia/frontends/tools/aio.py b/libervia/frontends/tools/aio.py index e8b7eab7..dfb9e9d8 100644 --- a/libervia/frontends/tools/aio.py +++ b/libervia/frontends/tools/aio.py @@ -141,8 +141,9 @@ def install_glib_asyncio_iteration(): if iteration_count == 0: loop.call_later(0.01, _glib_iteration) else: - # Schedule ourselves to run again on the next asyncio loop iteration - loop.call_soon(_glib_iteration) + # Work has been done, and there may still be some. Use a shorter delay to + # schedule ourselves again. + loop.call_later(0.001, _glib_iteration) # Kick off the GLib iteration loop.call_soon(_glib_iteration)