Skip to content

Commit aa5313e

Browse files
committed
[test-sourcekit-lsp] Use communicate to wait for subprocess to exit
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.
1 parent 7b48faa commit aa5313e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test-sourcekit-lsp/test-sourcekit-lsp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ def wait_for_exit(self, timeout: int) -> int:
110110
"""
111111
Wait for the LSP server to terminate.
112112
"""
113-
return self.process.wait(timeout)
113+
stdout, stderr = self.process.communicate(timeout=timeout)
114+
print("stdout before exit")
115+
print(stdout)
116+
print("stderr before exit")
117+
print(stderr)
118+
return self.process.returncode
114119

115120

116121
def main():
@@ -227,7 +232,7 @@ def main():
227232
connection.send_request("shutdown", {})
228233
connection.send_notification("exit", {})
229234

230-
return_code = connection.wait_for_exit(timeout=1)
235+
return_code = connection.wait_for_exit(timeout=5)
231236
if return_code == 0:
232237
print("OK")
233238
else:

0 commit comments

Comments
 (0)