Skip to content

Commit ac99feb

Browse files
authored
Merge pull request #10 from asford/dmypy_restart
Check dmypy status and kill hung daemons before run
2 parents 6b5b5fb + cbc2375 commit ac99feb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

mypy_ls/plugin.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,21 @@ def pylsp_lint(
172172
log.info("executing mypy args = %s", args)
173173
report, errors, _ = mypy_api.run(args)
174174
else:
175+
# If dmypy daemon is non-responsive calls to run will block.
176+
# Check daemon status, if non-zero daemon is dead or hung.
177+
# If daemon is hung, kill will reset
178+
# If daemon is dead/absent, kill will no-op.
179+
# In either case, reset to fresh state
180+
_, _err, _status = mypy_api.run_dmypy(["status"])
181+
if _status != 0:
182+
log.info(
183+
"restarting dmypy from status: %s message: %s", _status, _err.strip()
184+
)
185+
mypy_api.run_dmypy(["kill"])
186+
187+
# run to use existing daemon or restart if required
175188
args = ["run", "--"] + args
176-
177-
log.info("executing dmypy args = %s", args)
189+
log.info("dmypy run args = %s", args)
178190
report, errors, _ = mypy_api.run_dmypy(args)
179191

180192
log.debug("report:\n%s", report)

0 commit comments

Comments
 (0)