From 2ea86151f4e089f9d7d13f1fe380a90841b5b26f Mon Sep 17 00:00:00 2001 From: hetmankp Date: Wed, 17 May 2023 00:38:19 +1000 Subject: [PATCH] Fix pylint hang on file with many errors When pylint reports a large number of messages on a given file (200 should be sufficient on Linux), the returned output can exceed the maximum buffer size available to a pipe causing a deadlock as the pylint plugin waits for the pylint process to complete, while the pylint process waits for the pylint plugin to clear out the pipe. This hangs the pylint plugin and no linting is ever provided for the file. This bug only exists when the plugin lints files from the file system and is not an issue when pylsp.plugins.pylint.executable has been configured due to a different code path being used. --- pylsp/plugins/pylint_lint.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pylsp/plugins/pylint_lint.py b/pylsp/plugins/pylint_lint.py index b4a43972..f5d168de 100644 --- a/pylsp/plugins/pylint_lint.py +++ b/pylsp/plugins/pylint_lint.py @@ -101,9 +101,7 @@ def lint(cls, document, is_saved, flags=''): # pylint: disable=too-many-locals, with Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=cwd, universal_newlines=True) as process: - process.wait() - json_out = process.stdout.read() - err = process.stderr.read() + json_out, err = process.communicate() if err != '': log.error("Error calling pylint: '%s'", err)