Skip to content

Check dmypy status and kill hung daemons before run #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions mypy_ls/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,21 @@ def pylsp_lint(
log.info("executing mypy args = %s", args)
report, errors, _ = mypy_api.run(args)
else:
# If dmypy daemon is non-responsive calls to run will block.
# Check daemon status, if non-zero daemon is dead or hung.
# If daemon is hung, kill will reset
# If daemon is dead/absent, kill will no-op.
# In either case, reset to fresh state
_, _err, _status = mypy_api.run_dmypy(["status"])
if _status != 0:
log.info(
"restarting dmypy from status: %s message: %s", _status, _err.strip()
)
mypy_api.run_dmypy(["kill"])

# run to use existing daemon or restart if required
args = ["run", "--"] + args

log.info("executing dmypy args = %s", args)
log.info("dmypy run args = %s", args)
report, errors, _ = mypy_api.run_dmypy(args)

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