From 0914965c375f1cae52544e030f348935b85f8831 Mon Sep 17 00:00:00 2001 From: Zanie Date: Tue, 16 Jan 2024 11:46:52 -0600 Subject: [PATCH] Flush on each write; allow empty lines when parsing action --- scripts/hookd/hookd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/hookd/hookd.py b/scripts/hookd/hookd.py index 487b60bae..77c2bbbdd 100755 --- a/scripts/hookd/hookd.py +++ b/scripts/hookd/hookd.py @@ -307,7 +307,10 @@ class Action(enum.Enum): def parse_action(buffer: TextIO) -> Action: - action = buffer.readline().rstrip("\n") + # Wait until we receive non-empty content + action = None + while not action: + action = buffer.readline().rstrip("\n") return Action.from_str(action) @@ -428,7 +431,7 @@ def send_shutdown(file: TextIO): def write_safe(file: TextIO, *args: str): # Ensures thre are no newlines in the output args = [str(arg).replace("\n", "\\n") for arg in args] - print(*args, file=file) + print(*args, file=file, flush=True) #######################