diff --git a/bumblebee_status/modules/contrib/shell.py b/bumblebee_status/modules/contrib/shell.py index 566de42..7043778 100644 --- a/bumblebee_status/modules/contrib/shell.py +++ b/bumblebee_status/modules/contrib/shell.py @@ -61,6 +61,7 @@ class Module(core.module.Module): # if requested then run not async version and just execute command in this thread if not self.__async: self.__output = util.cli.execute(self.__command, shell=True, ignore_errors=True).strip() + core.event.trigger("update", [self.id], redraw_only=True) return # if previous thread didn't end yet then don't do anything @@ -71,6 +72,7 @@ class Module(core.module.Module): self.__current_thread = threading.Thread( target=lambda obj, cmd: obj.set_output( util.cli.execute(cmd, ignore_errors=True) + core.event.trigger("update", [self.id], redraw_only=True) ), args=(self, self.__command), ) diff --git a/bumblebee_status/util/cli.py b/bumblebee_status/util/cli.py index d14dc6a..4ef25d9 100644 --- a/bumblebee_status/util/cli.py +++ b/bumblebee_status/util/cli.py @@ -52,7 +52,19 @@ def execute( raise RuntimeError("{} not found".format(cmd)) if wait: - out, _ = proc.communicate() + timeout = 60 + try: + out, _ = proc.communicate(timeout=timeout) + except subprocess.TimeoutExpired as e: + logging.warning( + f""" + Communication with process pid={proc.pid} hangs for more + than {timeout} seconds. + If this is not expected, the process is stale, or + you might have run in stdout / stderr deadlock. + """ + ) + out, _ = proc.communicate() if proc.returncode != 0: err = "{} exited with code {}".format(cmd, proc.returncode) logging.warning(err)