Skip to content
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

Extension is launching far too many processes and not closing them correctly #3608

Closed
jcgoble3 opened this issue Dec 10, 2018 · 8 comments
Closed

Comments

@jcgoble3
Copy link

Environment data

  • VS Code version: 1.29.1
  • Extension version (available under the Extensions sidebar): 2018.11.0
  • OS and version: Ubuntu 18.04.1 LTS
  • Python version (& distribution if applicable, e.g. Anaconda): Built from source; python -VV output:
Python 3.7.0+ (heads/3.7:c721472fb8, Jul 15 2018, 01:57:17) 
[GCC 7.3.0]
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Expected behaviour

Opening an editor for a Python file in VSCode launches a Python process to run the extension for that editor. Closing the editor terminates the associated Python process, so that the number of Python processes is equal to the number of Python file editors currently open.

Actual behaviour

Opening an editor for a Python file in VSCode launches a Python process to run the extension for that editor. Closing the editor does NOT terminate the associated Python process, leaving it running forever unless either VSCode is closed completely or the process is manually killed via the operating system. As long as VSCode remains open, the number of Python processes grows without upper bound as Python editors are opened, slowly consuming large amounts of memory in a manner very similar to a fork bomb and pushing other processes into swap, which eventually brings the entire operating system to a halt. I had over 5 GiB of stuff in swap by the time I realized what was happening, and it took 5 to 10 minutes for the computer to respond to my attempts to close programs.

Steps to reproduce:

  1. Open System Monitor in Ubuntu, sort processes alphabetically, and scroll to "python" (or where python would appear).
  2. In VSCode, open several Python files. Note in System Monitor that a Python process is launched for each one. This is expected.
  3. Keeping VSCode open, close the editors for the Python files. Note in System Monitor that the Python processes continue to live, which is the bug.
  4. Open more Python files. More Python processes are launched for each one, even if the file is one that was previously opened in the same session.
  5. Repeat steps 3 and 4 as often as desired, and watch the number of Python processes grow without limit. I recommend stopping before you effectively fork-bomb your system.
  6. Close VSCode completely. All Python processes finally terminate.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Jedi Python language engine.
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:1446  INFO no standard startup: panel is active
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Looking for parseable documents...
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Create file systemwatcher with pattern */python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: {"$mid":1,"fsPath":"/home/jonathan/git/blackjack","external":"file:///home/jonathan/git/blackjack","path":"/home/jonathan/git/blackjack","scheme":"file"}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Create file systemwatcher with pattern */python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: {"$mid":1,"fsPath":"/home/jonathan/git/blackjack","external":"file:///home/jonathan/git/blackjack","path":"/home/jonathan/git/blackjack","scheme":"file"}, Return Value: UNABLE TO DETERMINE VALUE
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: undefined, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: undefined, Return Value: UNABLE TO DETERMINE VALUE
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Found no documents
5/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Failed to get interpreter information for '/home/jonathan/.local/bin/python3.3' SyntaxError: Unexpected token [ in JSON at position 168
    at JSON.parse (<anonymous>)
    at d.<anonymous> (/home/jonathan/.vscode/extensions/ms-python.python-2018.11.0/src/client/common/process/pythonProcess.ts:42:1)
    at Generator.next (<anonymous>)
    at s (/home/jonathan/.vscode/extensions/ms-python.python-2018.11.0/src/client/common/process/pythonProcess.ts:12:42)
    at <anonymous>

(Annotation: The "python3.3" interpreter referenced above is NOT the one running the extension, or one that I use in any way. It is an old one that I intend to delete when I have some time to clean things up.)

t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:294 [Extension Host] Python Extension: stderr jediProxy, Error (stderr) completion.py:620: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='w' encoding='UTF-8'>
  response = self._process_request(rq)
@jcgoble3
Copy link
Author

Also, all of these Python processes show the same command line: /home/jonathan/bin/py /home/jonathan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles/jedi/evaluate/compiled/subprocess/__main__.py /home/jonathan/.vscode/extensions/ms-python.python-2018.11.0/pythonFiles 3.7.0

So it's pretty clear that this extension is the cause.

@kristofferpeterhansel
Copy link

kristofferpeterhansel commented Dec 10, 2018

I seem to have been experiencing this as well. I think after the last extension update. And it is bad enough that over time it will spawn enough processes that my system will stop being able to fork new processes (not entirely sure what limit is exhausted. As I seem to still be able to open applications)

For me I am fairly sure it is the selected python in my project though. Which in the case is 2.7 though a virtualenv

@kristofferpeterhansel
Copy link

From a quick observation it seems highly likely to be related to the machine sleeping.

All morning I have had two processes. Coming back from lunch and waking my machine I now have 11.

@kristofferpeterhansel
Copy link

It could also be an issue with Jedi (davidhalter/jedi#1242) itself. Perhaps the extension upgraded to a problematic version?

@frizz925
Copy link

frizz925 commented Dec 10, 2018

This also happens to me on macOS 10.14.1. Same VS Code, extension, and Python versions. But with pipenv's virtualenv.

@frizz925
Copy link

Seems like the same issue as #3514

@kristofferpeterhansel
Copy link

You are right @frizz925 . Somehow I missed that one

@brettcannon
Copy link
Member

Duplicate of #3514

@brettcannon brettcannon marked this as a duplicate of #3514 Dec 10, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants