Skip to content

Commit a098c1e

Browse files
committed
Well behave by killing the process, may the timout expires.
1 parent c47356b commit a098c1e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎language_tool/__init__.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,18 @@ def get_version():
475475
universal_newlines=True,
476476
startupinfo=startupinfo
477477
)
478-
out = proc.communicate(timeout=LanguageTool._TIMEOUT)[0]
479-
match = version_re.search(out)
478+
try:
479+
outs = proc.communicate(timeout=LanguageTool._TIMEOUT)[0]
480+
except subprocess.TimeoutExpired:
481+
proc.kill()
482+
errs = proc.communicate()[1]
483+
raise Error(errs)
484+
match = version_re.search(outs)
480485

481486
if not match:
482487
match = version_re.search(get_directory())
483488
if not match:
484-
raise Error("unexpected version output: {!r}".format(out))
489+
raise Error("unexpected version output: {!r}".format(outs))
485490
version = match.group(1)
486491
cache["version"] = version
487492
return version

0 commit comments

Comments
 (0)