Open duedive opened 4 months ago
@duedive Can you capture the command line of these processes?
It is nothing I run myself, but when trying to capture the command line of the processes (as you suggested) I found the issue based on the open files and ports information from Activity Monitor.
All processes I checked show this (below) which seems to create an endless loop of activating and deactivating virtual environments:
/Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/deactivate/zsh
/bin/zsh
/usr/lib/zsh/5.9/zsh/parameter.so
/usr/lib/zsh/5.9/zsh/zutil.so
/usr/lib/zsh/5.9/zsh/terminfo.so
/usr/lib/zsh/5.9/zsh/zleparameter.so
/usr/lib/zsh/5.9/zsh/langinfo.so
/usr/lib/zsh/5.9/zsh/complist.so
/usr/lib/zsh/5.9/zsh/complete.so
/usr/lib/zsh/5.9/zsh/zle.so
/dev/ttys014
/dev/null
/dev/null
/dev/ttys014
/Users/rle/.zshrc
/Users/rle/.oh-my-zsh/oh-my-zsh.sh
/Users/rle/.oh-my-zsh/custom/plugins/virtualenv-autoload/virtualenv-autoload.plugin.zsh
The zsh processes have a bash process as parent showing:
/Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/deactivate/zsh
/bin/bash
/dev/ttys014
/dev/null
/dev/null
/Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/deactivate/zsh/deactivate
When I remove/disable the virtualenv-autoload.plugin.zsh
script, then the problem does no longer happen. This file is added by me as a plugin to Oh my zsh to load a virtual environment when I navigate into a folder with a .venv folder, and to deactivate it once I leave it. It contains:
# Automatically activate (and deactivate on leaving) a Python virtualenv
# if there is a .venv folder in a directory you are entering.
autoload -U add-zsh-hook
load-venv() {
MYVENV=./.venv
# when you cd into a folder that contains $MYVENV
if [[ -d $MYVENV ]]; then
source $MYVENV/bin/activate > /dev/null 2>&1
python_version=$(python --version)
echo "Activated virtualenv ($MYVENV), using $python_version"
elif [[ ! -d $MYVENV ]]; then
# when you cd into a folder that doesn't
deactivate > /dev/null 2>&1
fi
}
add-zsh-hook chpwd load-venv
load-venv
I do not understand why this works with Python plugin v2024.8.1 and fails with v2024.10.0. Maybe something changed in the loading of the virtual environments process or how VSCode creates terminals.
Anyway it seems it is an issue specific to my environment and I have now a work around by skipping to run the virtual environment activation in my plug-in if the terminal is started by VSCode.
This has been the culprit for my issues. Activity Monitor shows batches of zsh
keep increasing every second until I get EAGAIN
error. Reverting to v2024.8.1 solves the issue. Subscribing for updates.
I have the same issues. Downgrading to v2024.8.1 fixes the problem for me, too.
@deanq @zakaryan2004 are you also using Oh my zsh with some plug-in to load virtual environments, or its a different cause for you? (just curious)
@deanq @zakaryan2004 are you also using Oh my zsh with some plug-in to load virtual environments, or its a different cause for you? (just curious)
Actually, yes. I have oh my zsh and a plugin that activates virtual environments automatically.
Yes. Exactly zsh with virtualenv where it auto loads when cd-ing to a directory where venv folder exists. Typical setup like OP.
On Sat, Jul 20, 2024 at 11:54 PM Gegham Zakaryan @.***> wrote:
@deanq https://github.com/deanq @zakaryan2004 https://github.com/zakaryan2004 are you also using Oh my zsh with some plug-in to load virtual environments, or its a different cause for you? (just curious)
Actually, yes. I have oh my zsh and a plugin that activates virtual environments automatically.
— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-python/issues/23820#issuecomment-2241500927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIWU6CT7IFTATG3T6LEM2TZNNLLPAVCNFSM6AAAAABK6DWZVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBRGUYDAOJSG4 . You are receiving this because you were mentioned.Message ID: @.***>
Ok, then you might have a plug-in similar to the following in a file like: ~/.oh-my-zsh/custom/plugins/virtualenv-autoload/virtualenv-autoload.plugin.zsh
1 # Automatically activate (and deactivate on leaving) a Python virtualenv
2 # if there is a .venv folder in a directory you are entering.
3
4 autoload -U add-zsh-hook
5
6 load-venv() {
7 if [[ "$TERM_PROGRAM" == "vscode" ]]; then
8 echo "Oh my Zsh: Terminal is 'vscode', skipping virtualenv-autoloader..."
9 else
10 MYVENV=./.venv
11 # when you cd into a folder that contains $MYVENV
12 if [[ -d $MYVENV ]]; then
13 source $MYVENV/bin/activate > /dev/null 2>&1
14 python_version=$(python --version)
15 echo "Activated virtualenv ($MYVENV), using $python_version"
16 elif [[ ! -d $MYVENV ]]; then
17 # when you cd into a folder that doesn't
18 deactivate > /dev/null 2>&1
19 fi
20 fi
21 }
22
23 add-zsh-hook chpwd load-venv
24 load-venv
Adding lines 7-9 and 20 solved the issue for me. I basically encapsulated the original plug-in to only run if it is not having vscode as terminal. Maybe you can apply a similar solution to your plug-in. Good luck.
This could still be only a work around, and there might be some issue with the Python plugin, since above worked without problems before update to v2024.10.x.
This also fixes my issue with VScode + zsh + auto venv. What behaviour was changed in v2024.10.0 that causes this effect?
Amazing, so grateful that I found this issue. Have the exact same setup and VS code have been taking up all my ram for the past few months 😄
I guess I'll have to keep pegging the installed version to old ones until this is fixed.
Type: Bug
Behaviour
After update (automatically) to v2024.10.0 of the Python extension opening any of my existing Python projects starts about 2000 zsh and bash processes (going from ca 600 processes to 2500-3000 processes in total). After wich working with the computer becomes very slow.
Reverting to Python extension v2024.8.1 solved the issue. The issue does also exist with the V2024.11.x pre-view version.
The zsh processes get killed very slowly when closing VS Code. Doing
sudo pkill -a zsh bash
speeds it up.I am using latest Mac OS (14.5, Intel) with zsh 5.9 and
Oh my Zsh
. Python projects using a virtual environment with Python 3.12 or 3.9.Just starting VS Code without a Python project, does not cause the problem.
Closing the terminal windows does not have an effect (new processes still get started).
Starting new zsh processes stops around 3000 open processes, when some system limit for open processes is reached. At that point I usually cannot open a new Mac Terminal window any longer. Process creation also stops after closing VS Code.
Steps to reproduce:
Open VS Code with a Python project and Python v2024.10.0 or higher extension.
There are a number of errors in the Output for Python (see below) that pixi cannot be found, but I am not using this, so its probably ok? In the output with version Python v2024.8.1, there are no errors.
Diagnostic data
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)``` 2024-07-16 10:39:44.598 [info] Experiment 'pythonaa' is active 2024-07-16 10:39:44.598 [info] Experiment 'pythonCreateEnvOnPipInstall' is active 2024-07-16 10:39:44.598 [info] Experiment 'pythonRecommendTensorboardExt' is active 2024-07-16 10:39:44.598 [info] Experiment 'pythonSurveyNotification' is active 2024-07-16 10:39:44.598 [info] Experiment 'pythonTerminalEnvVarActivation' is active 2024-07-16 10:39:44.598 [info] Experiment 'pythonTestAdapter' is active 2024-07-16 10:39:44.598 [error] Reading directory to watch failed [Error: ENOENT: no such file or directory, scandir '/Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.pixi/envs' at Object.readdirSync (node:fs:1515:3) at t.readdirSync (node:electron/js2c/node_init:2:11289) at /Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/out/client/extension.js:2:574598 at /Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/out/client/extension.js:2:574789 at Array.map ()
at d.initWatchers (/Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/out/client/extension.js:2:574507)
at async d.ensureWatchersReady (/Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/out/client/extension.js:2:536827)] {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.pixi/envs'
}
2024-07-16 10:39:44.598 [error] Dir "/Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.pixi/envs" is not watchable (directory does not exist)
2024-07-16 10:39:44.598 [info] Default formatter is set to ms-python.autopep8 for workspace /Users/rle/Documents/Softwerk/projects/agoy/agoy-argen
2024-07-16 10:39:44.598 [info] Starting Environment refresh
2024-07-16 10:39:44.598 [info] Searching for interpreters in posix paths locator
2024-07-16 10:39:44.598 [info] Searching for pyenv environments
2024-07-16 10:39:44.598 [info] Searching for conda environments
2024-07-16 10:39:44.598 [info] Searching for global virtual environments
2024-07-16 10:39:44.598 [info] Searching for custom virtual environments
2024-07-16 10:39:44.598 [info] pyenv is not installed
2024-07-16 10:39:44.598 [info] Finished searching for pyenv environments: 77 milliseconds
2024-07-16 10:39:44.598 [info] > conda info --json
2024-07-16 10:39:44.598 [info] > pixi --version
2024-07-16 10:39:44.598 [error] [Error: spawn pixi ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
errno: -2,
code: 'ENOENT',
syscall: 'spawn pixi',
path: 'pixi',
spawnargs: [ '--version' ]
}
2024-07-16 10:39:44.598 [info] > hatch env show --json
2024-07-16 10:39:44.598 [info] cwd: .
2024-07-16 10:39:44.598 [info] Finished searching for global virtual envs: 419 milliseconds
2024-07-16 10:39:44.598 [info] Finished searching for custom virtual envs: 419 milliseconds
2024-07-16 10:39:44.607 [info] > pyenv which python
2024-07-16 10:39:44.607 [info] cwd: .
2024-07-16 10:39:44.648 [info] Found: /usr/bin/python3 --> /usr/bin/python3
2024-07-16 10:39:44.751 [info] Found: /usr/local/bin/python3 --> /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/bin/python3.12
2024-07-16 10:39:44.755 [info] Found: /usr/local/bin/python3.10 --> /usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/bin/python3.10
2024-07-16 10:39:44.759 [info] > /usr/local/bin/python3 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:44.767 [info] Found: /usr/local/bin/python3.11 --> /usr/local/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/bin/python3.11
2024-07-16 10:39:44.771 [info] > ./.venv/bin/python -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:44.924 [info] Found: /usr/local/bin/python3.12 --> /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/bin/python3.12
2024-07-16 10:39:44.927 [info] Python interpreter path: ./.venv/bin/python
2024-07-16 10:39:46.858 [warning] Shell integration may not be active, environment activated may be overridden by the shell.
2024-07-16 10:39:46.859 [warning] could not find a pixi interpreter for the interpreter at /Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.venv/bin/python
2024-07-16 10:39:46.964 [info] Found: /usr/local/bin/python3.8 --> /usr/local/Cellar/python@3.8/3.8.19/Frameworks/Python.framework/Versions/3.8/bin/python3.8
2024-07-16 10:39:47.049 [info] Found: /usr/local/bin/python3.9 --> /usr/local/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/bin/python3.9
2024-07-16 10:39:47.120 [info] > /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:47.193 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/printEnvVariables.py
2024-07-16 10:39:47.193 [info] shell: zsh
2024-07-16 10:39:48.154 [info] > /usr/local/bin/python3 ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/printEnvVariables.py
2024-07-16 10:39:48.154 [info] shell: zsh
2024-07-16 10:39:48.352 [info] > /usr/local/bin/python3.10 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:49.192 [info] > /usr/local/bin/python3.11 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:49.327 [info] Prepending environment variable PS1 in collection with (.venv) {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-07-16 10:39:49.327 [info] Prepending environment variable PATH in collection with /Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/deactivate/zsh:/Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.venv/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-07-16 10:39:49.327 [info] Setting environment variable VIRTUAL_ENV in collection to /Users/rle/Documents/Softwerk/projects/agoy/agoy-argen/.venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-07-16 10:39:49.327 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to (.venv) {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-07-16 10:39:49.389 [info] Finished searching for interpreters in posix paths locator: 5268 milliseconds
2024-07-16 10:39:49.390 [info] > /usr/local/bin/python3.8 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:49.423 [info] > /usr/local/bin/python3.9 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:49.525 [info] Environments refresh paths discovered (event): 5413 milliseconds
2024-07-16 10:39:49.526 [info] Environments refresh paths discovered: 5414 milliseconds
2024-07-16 10:39:49.532 [info] Environments refresh finished (event): 5420 milliseconds
2024-07-16 10:39:49.540 [info] Environment refresh took 5429 milliseconds
2024-07-16 10:39:49.606 [info] > /Library/Developer/CommandLineTools/usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/interpreterInfo.py
2024-07-16 10:39:50.212 [info] Starting Pylance language server.
2024-07-16 10:39:50.331 [info] Send text to terminal: /usr/local/bin/python3 /Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/printEnvVariablesToFile.py /Users/rle/.vscode/extensions/ms-python.python-2024.10.0-darwin-x64/python_files/deactivate/zsh/envVars.txt
```
Extension version: 2024.8.1 VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:07:54.982Z) OS version: Darwin x64 23.5.0 Modes:
python.languageServer
setting: PylanceUser Settings
``` venvPath: ""
languageServer: "Pylance"
```
Installed Extensions
|Extension Name|Extension Id|Version| |---|---|---| |.NET Install Tool|ms-dotnettools.vscode-dotnet-runtime|2.0.9| |Amazon Q|amazonwebservices.amazon-q-vscode|1.15.0| |autoDocstring - Python Docstring Generator|njpwerner.autodocstring|0.6.1| |autopep8|ms-python.autopep8|2024.0.0| |AWS Toolkit|amazonwebservices.aws-toolkit-vscode|3.14.0| |Better Comments|aaron-bond.better-comments|3.0.2| |Better Solarized|ginfuru.ginfuru-better-solarized-dark-theme|0.10.9| |Braver's Solarized|Braver.vscode-solarized|2.0.4| |C/C++|ms-vscode.cpptools|1.20.5| |C#|ms-dotnettools.csharp|2.34.12| |Checkstyle for Java|shengchen.vscode-checkstyle|1.4.2| |Code Spell Checker|streetsidesoftware.code-spell-checker|3.0.1| |CodeMetrics|kisstkondoros.vscode-codemetrics|1.26.1| |CodeWhisperer for command line|amazonwebservices.codewhisperer-for-command-line-companion|0.1.0| |Comment Anchors|ExodiusStudios.comment-anchors|1.10.4| |Cordova Tools|msjsdiag.cordova-tools|2.7.0| |Debugger for Java|vscjava.vscode-java-debug|0.58.0| |Dependency Graph Viewer|Antarpreet.dependency-graph-viewer|0.0.8| |Deploy (Reloaded)|mkloubert.vscode-deploy-reloaded|0.89.0| |Dev Containers|ms-vscode-remote.remote-containers|0.375.1| |Docker|ms-azuretools.vscode-docker|1.29.1| |EBNF Tools|igochkov.vscode-ebnf|1.3.1| |ESLint|dbaeumer.vscode-eslint|3.0.10| |Excel Viewer|GrapeCity.gc-excelviewer|4.2.59| |Extension Pack for Java|vscjava.vscode-java-pack|0.27.0| |GitLens — Git supercharged|eamodio.gitlens|15.2.0| |HashiCorp Terraform|hashicorp.terraform|2.32.0| |IntelliCode|VisualStudioExptTeam.vscodeintellicode|1.3.1| |isort|ms-python.isort|2023.10.1| |Java Project Explorer|yaozheng.vscode-java-copilot|0.1.4| |JavaScript Debugger|ms-vscode.js-debug|1.91.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |JS Complexity Analysis|TomiTurtiainen.js-complexity-analysis|2.0.0| |Jupyter|ms-toolsai.jupyter|2024.6.0| |Jupyter Cell Tags|ms-toolsai.vscode-jupyter-cell-tags|0.1.9| |Jupyter Keymap|ms-toolsai.jupyter-keymap|1.1.2| |Jupyter Notebook Renderers|ms-toolsai.jupyter-renderers|1.0.18| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |Language Support for Java(TM) by Red Hat|redhat.java|1.32.0| |LaTeX language support|torn4dom4n.latex-support|3.10.0| |LaTeX Workshop|James-Yu.latex-workshop|10.1.0| |Markdown PDF|yzane.markdown-pdf|1.5.0| |Markdown Preview Mermaid Support|bierner.markdown-mermaid|1.23.1| |Markdown+Math|goessner.mdmath|2.7.4| |markdownlint|DavidAnson.vscode-markdownlint|0.55.0| |Matlab Unofficial|Gimly81.matlab|3.0.2| |matlab-formatter|AffenWiesel.matlab-formatter|2.11.0| |Maven for Java|vscjava.vscode-maven|0.44.0| |php cs fixer|junstyle.php-cs-fixer|0.3.13| |PHP Debug|xdebug.php-debug|1.35.0| |PHP Extension Pack|xdebug.php-pack|1.0.3| |PHP IntelliSense|felixfbecker.php-intellisense|2.3.14| |PHP IntelliSense|zobo.php-intellisense|1.3.3| |Prettier ESLint|rvest.vs-code-prettier-eslint|6.0.0| |Project Manager for Java|vscjava.vscode-java-dependency|0.23.7| |Pylance|ms-python.vscode-pylance|2024.7.1| |Python|ms-python.python|2024.8.1| |Python Debugger|ms-python.debugpy|2024.8.0| |Rainbow CSV|mechatroner.rainbow-csv|3.12.0| |SonarLint|SonarSource.sonarlint-vscode|4.7.0| |Swedish - Code Spell Checker|streetsidesoftware.code-spell-checker-swedish|1.3.1| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9| |Test Runner for Java|vscjava.vscode-java-test|0.41.1| |XML Tools|DotJoshJohnson.xml|2.5.1|System Info
|Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz (8 x 2300)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|21, 159, 137| |Memory (System)|16.00GB (0.13GB free)| |Process Argv|--crash-reporter-id 20def760-1166-41f9-8c27-dbc511f7b9ad| |Screen Reader|yes| |VM|0%|
A/B Experiments
``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelt:31048053 dsvsc021:30996838 9c06g630:31013171 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 impr_priority:31094925 pythonrstrctxt:31093869 hdi1a554:31097393 ```