matangover/mypy-vscode

dmypy processes are not stopped when vscode is stopped

alehed opened this issue · 8 comments

I don't know whether this is by design or by accident, but dmypy processes are not stopped when vscode is stopped.

This can become a problem when opening a workspace with mutliple python projects since each daemon can consume around 100 MB and closing vscode does not result in getting the memory back.

Looking at other plugins, it seems like the common thing to do is to spawn the processes as child processes of the extension.

Definitely not by design, I designed it so that dmypy is killed when VS Code exits. If it's not being killed it's a bug, can you give me steps to reproduce + versions of everything?

Ok. good. I can reproduce it by doing:

  1. Creating a folder containing a single python file. I used
#!/usr/bin/env python3

print("hi " + 1 + ".")
  1. Restarting the computer
  2. Opening htop and filtering for dmypy
  3. Navigating to the folder and opening vscode with code . (it should show the type error)
  4. Closing vscode again
  5. Checking in htop that dmypy is still running

When looking at the process hierarchy, it is apparent that dmypy gets launched as a direct child of /lib/systemd/systemd --user.

Versions:

vscode:

Version: 1.64.1
Commit: d6ee99e4c045a6716e5c653d7da8e9ae6f5a8b03
Date: 2022-02-07T17:17:47.733Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.13.0-28-generic

mypy extension: v0.2.1
dmypy: dmypy 0.910

Thanks for the details! I have identified the regression, it was due to an internal change in VSCode which caused my daemon stopping code to stop working.

The daemon being launched as a child of pid 1 was not related to the problem. When you run e.g. dmypy run (which is what I'm doing in the extension), dmypy daemonizes itself on purpose. I then stop it manually with dmypy stop when the extension deactivates.

I could theoretically launch the daemon process in the foreground using the command dmypy daemon (which seems undocumented) but I prefer to leave it as is.

Thanks for following up. Is there a vscode bug report to track this?

There's no bug in VS Code, it's an internal change that affected my extension in a way I didn't expect. I have fixed the issue and will make a release soon

Ah, ok. Sorry, I misunderstood. Thanks!

I've released a new version which fixes the bug. If for any reason you still find dangling daemon processes please enable the mypy.debugLogging option and attach the log.

Awesome, thanks!