Skip to content

Commit 306595c

Browse files
ahoppenbnbarham
authored andcommitted
[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. (cherry picked from commit aa5313e)
1 parent 65f7d50 commit 306595c

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
@@ -108,7 +108,12 @@ def wait_for_exit(self, timeout: int) -> int:
108108
"""
109109
Wait for the LSP server to terminate.
110110
"""
111-
return self.process.wait(timeout)
111+
stdout, stderr = self.process.communicate(timeout=timeout)
112+
print("stdout before exit")
113+
print(stdout)
114+
print("stderr before exit")
115+
print(stderr)
116+
return self.process.returncode
112117

113118

114119
def main():
@@ -225,7 +230,7 @@ def main():
225230
connection.send_request("shutdown", {})
226231
connection.send_notification("exit", {})
227232

228-
return_code = connection.wait_for_exit(timeout=1)
233+
return_code = connection.wait_for_exit(timeout=5)
229234
if return_code == 0:
230235
print("OK")
231236
else:

0 commit comments

Comments
 (0)