From e30c00733a68a331d91c02066086ccd4daa4888f Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 24 Feb 2022 11:47:56 +0100 Subject: [PATCH] fix(linux): Don't start ibus-daemon multiple times This change adds a 1s sleep after restarting ibus before checking that it actually runs. Hopefully this will solve the problem. Since this bug is hard to reproduce, we also log a critical error for the other code path this could happen. Fixes #6237. --- linux/keyman-config/keyman_config/ibus_util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linux/keyman-config/keyman_config/ibus_util.py b/linux/keyman-config/keyman_config/ibus_util.py index 0ba5d773f3..0f26f7b2e2 100644 --- a/linux/keyman-config/keyman_config/ibus_util.py +++ b/linux/keyman-config/keyman_config/ibus_util.py @@ -91,7 +91,9 @@ def _verify_ibus_daemon(): ps = subprocess.run(('ps', '--user', user, '-o', 's=', '-o', 'cmd'), stdout=subprocess.PIPE).stdout if not re.search('^[^ZT] ibus-daemon .*--xim.*', ps.decode('utf-8'), re.MULTILINE): _start_ibus_daemon(realuser) - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + # Log criticial error in order to track down #6237 + logging.critical('getting ibus-daemon failed (%s: %s)', type(e), e.args) _start_ibus_daemon(realuser) @@ -130,6 +132,7 @@ def restart_ibus(bus=None): except Exception as e: logging.warning("Failed to restart IBus") logging.warning(e) + time.sleep(1) # 1s _verify_ibus_daemon()