Rogue Python Processes with High CPU Consumption
See original GitHub issueOpening python (.py) files in Visual Studio Code (VSC) resulted in rogue python3.8 processes that did not terminate after closing the files or quitting VSC. The processes consumed over 81% of the CPU and were associated with rapid loss of battery power on a MacBook Air (M1, 2020). This was repeatable with an empty file with a .py extension.
Steps to Reproduce the Problem
. Started VSC without any installed extensions. . Opened existing emptyfile.py file with no content. . No python3.8 processes running. . Closed emptyfile.py file. . Closed VSC window. . Quit VSC. . No python3.8 processes running. . Opened VSC. . Installed Python extension. This also installed jupyter extension. . No python3.8 processes running. . Opened emptyfile.py file. . Checked for python processes:
% ps -ax | grep python
4286 ?? 0:00.27 /Users/Scott/anaconda3/bin/python /Users/Scott/.vscode/extensions/ms-python.python-2021.2.625869727/pythonFiles/runJediLanguageServer.py
4299 ?? 0:00.15 /Users/Scott/anaconda3/bin/python /Users/Scott/anaconda3/lib/python3.8/site-packages/jedi/inference/compiled/subprocess/__main__.py /Users/Scott/anaconda3/lib/python3.8/site-packages 3.8.5
. CPU use around 5%
. Closed emptyfile.py file. . The two processes from ps above still present. . Closed VSC window. . python3.8 processes, PID 4286, now using about 81% CPU. . Quit VSC. . python3.8 processes, PID 4286, still using about 81% CPU. . Process, PID 4289, from above ps still running. . kill 4286 from terminal. . Processes, PIDs 4286 and 4299, from above ps, no longer present. . CPU use back down to around 6%.
Configuration
Visual Studio Code Version: 1.54.1 Commit: f30a9b73e8ffc278e71575118b6bf568f04587c8 Date: 2021-03-04T22:42:18.719Z (19 hrs ago) Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Darwin x64 20.3.0
Model Name: MacBook Air Model Identifier: MacBookAir10,1 Chip: Apple M1 Memory: 16 GB System Firmware Version: 6723.81.1
System Software Overview: System Version: macOS 11.2.2 (20D80) Kernel Version: Darwin 20.3.0
Python 3.8.5
VSC Extensions
Python ms-python.python v2021.2.625869727
Jupyter ms-toolsai.jupyter Microsoft 10,388,239 Repository License v2021.3.619093157
Issue Analytics
- State:
- Created 3 years ago
- Reactions:16
- Comments:55 (25 by maintainers)
Top GitHub Comments
Thanks for giving this info! I think the problem may be one of our new features, can you try disabling it by following the steps below, and see if that fixes the problem you’re experiencing?
The problem no longer occurs after following the steps outlined by luabud, which added
“python.experiments.optOutFrom”: [“pythonJediLSP”], to settings.json.