Skip to content

Commit 22251fa

Browse files
rduganccordoba12
andauthored
Fix flake8 io deadlock (#757)
Co-authored-by: Carlos Cordoba <[email protected]>
1 parent 3057ac2 commit 22251fa

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pyls/plugins/flake8_lint.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ def run_flake8(args):
5858
cmd = ['python', '-m', 'flake8']
5959
cmd.extend(args)
6060
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
61-
stderr = p.stderr.read().decode()
61+
(stdout, stderr) = p.communicate()
6262
if stderr:
63-
log.error("Error while running flake8 '%s'", stderr)
64-
stdout = p.stdout
65-
return stdout.read().decode()
63+
log.error("Error while running flake8 '%s'", stderr.decode())
64+
return stdout.decode()
6665

6766

6867
def build_args(options, doc_path):

test/plugins/test_flake8_lint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_flake8_lint(config):
5757

5858
def test_flake8_config_param(config):
5959
with patch('pyls.plugins.flake8_lint.Popen') as popen_mock:
60+
mock_instance = popen_mock.return_value
61+
mock_instance.communicate.return_value = [bytes(), bytes()]
6062
flake8_conf = '/tmp/some.cfg'
6163
config.update({'plugins': {'flake8': {'config': flake8_conf}}})
6264
_name, doc = temp_document(DOC)

0 commit comments

Comments
 (0)