From aa5313ec1e4e391beaf857c647c8d9565065d375 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Wed, 27 Nov 2024 14:16:49 +0100 Subject: [PATCH] [test-sourcekit-lsp] Use `communicate` to wait for subprocess to exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait says that `wait` can deadlock if the process use pipes (which we do) and if it generates too much output. Might fix rdar://140425949 but I’m entirely certain because that radar looks like a crash in LLVM, which I don’t fully understand. --- test-sourcekit-lsp/test-sourcekit-lsp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test-sourcekit-lsp/test-sourcekit-lsp.py b/test-sourcekit-lsp/test-sourcekit-lsp.py index 969388d..062c12c 100644 --- a/test-sourcekit-lsp/test-sourcekit-lsp.py +++ b/test-sourcekit-lsp/test-sourcekit-lsp.py @@ -110,7 +110,12 @@ def wait_for_exit(self, timeout: int) -> int: """ Wait for the LSP server to terminate. """ - return self.process.wait(timeout) + stdout, stderr = self.process.communicate(timeout=timeout) + print("stdout before exit") + print(stdout) + print("stderr before exit") + print(stderr) + return self.process.returncode def main(): @@ -227,7 +232,7 @@ def main(): connection.send_request("shutdown", {}) connection.send_notification("exit", {}) - return_code = connection.wait_for_exit(timeout=1) + return_code = connection.wait_for_exit(timeout=5) if return_code == 0: print("OK") else: