Repository navigation
Description
Type: Bug
Behaviour
With Jedi as language server (python.languageServer: "Jedi", or "Default" without Pylance), changing the
active interpreter and restarting the language server in quick succession leaves extra
run-jedi-language-server.py processes running. Completion in Python files then hangs (the suggest widget
stays at "Loading..." / no results) until the window is reloaded.
Each interpreter change stops the Jedi server and starts a new one with the new interpreter. When the next
stop or restart arrives while a start is still in progress, the server that is being started is not stopped
and stays running without being connected/tracked.
A related symptom: when python.analysis.restartLanguageServer runs before the extension has started Jedi
for the first time (e.g. while it is still resolving the interpreter at startup), it starts a server that is
never connected. Completion then shows nothing in the whole window until a reload.
Also, the Jedi handler of python.analysis.restartLanguageServer does not return the restart promise, so
await vscode.commands.executeCommand('python.analysis.restartLanguageServer') resolves immediately. Callers
therefore cannot wait for the restart to finish to avoid overlapping it.
Expected
- At any time at most one Jedi server process per workspace folder, regardless of how quickly interpreter
changes and restarts follow each other (a pending start is cancelled/stopped, or requests are serialized). python.analysis.restartLanguageServerresolves after the new server is running, as with Pylance.
Actual
- After "switch away, switch back, restart" sequences, more than one
run-jedi-language-server.pyprocess
runs for one workspace folder (expected: 1). - Completion hangs until
Developer: Reload Window.
Steps to reproduce
-
Settings:
"python.languageServer": "Jedi". Workspace with a virtual environment.venvand at least one
other interpreter available (e.g. a global Python). -
Open a
.pyfile and wait until completion works. -
Run the following sequence of calls from an extension. We hit this through our own extension, which
switches the interpreter away and back so that language servers pick up changed.pthfiles; the snippet
shows the calls it makes (it waits up to 1 s between the two switches until the venv'spython.exeis
released):import { PythonExtension } from '@vscode/python-extension'; const api = await PythonExtension.api(); const folder = vscode.workspace.workspaceFolders![0]; await api.environments.updateActiveEnvironmentPath(otherPythonPath, folder); await api.environments.updateActiveEnvironmentPath(venvPythonPath, folder); await vscode.commands.executeCommand('python.analysis.restartLanguageServer');
Doing the same by hand (Python: Select Interpreter twice quickly, then Python: Restart Language Server)
may also work, but is timing dependent. -
Count the Jedi processes (Windows PowerShell):
Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object CommandLine -match 'run-jedi-language-server' | Select-Object ProcessId, CommandLine
-
Try completion in the open
.pyfile.
Diagnostic data
- Python extension version: 2026.10.0 (ms-python.python-2026.10.0-win32-x64)
- Python Environments extension: 1.42.0
- VS Code version: 1.127.0 (4fe60c8b1cdac1c4c174f2fb180d0d758272d713), x64
- OS: Windows 11 Enterprise 10.0.22631
- Language server: Jedi (Pylance not installed /
python.languageServer: "Jedi") - Python version: 3.14.5
Notes
We have only seen this with Jedi. Pylance does not run inside the selected interpreter, so an interpreter
change does not replace its process.
Activity