Fast Pylance startup: don't block activation on environment enumeration#26019
Merged
Conversation
Make interpreter resolution non-blocking so Pylance can start immediately, even during a full environment refresh: - interpreterService.getActiveInterpreter races resolution against a 100ms timeout, serving the last-known/persisted interpreter when discovery is slow (the real value still resolves and updates listeners). - activationManager no longer awaits auto-select interpreter; it races a short timeout. - pythonEnvironments/index sets Conda.setSkipDeepProbe(true) when the environments extension is active, and conda.ts honors it to avoid slow deep probes. - envExt/api.legacy and interpreterService de-duplicate in-flight resolutions. - testController: defer project discovery (return undefined and self-heal on environment change) instead of throwing 'No Python environment found' when an env isn't assigned yet during fast startup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
heejaechang
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Part of #26020
Summary
Make Python interpreter resolution non-blocking so Pylance can start immediately, even while the environment extension is doing a full refresh on first run.
Previously, activation awaited interpreter auto-selection and
getActiveInterpreter()could block for the entire environment-enumeration window (tens of seconds on large/conda setups), which delayed the language server from starting.Changes
interpreter/interpreterService.ts–getActiveInterpreter()now races resolution against a ~100ms timeout. If discovery is slow it returns the last-known/persisted interpreter immediately; the real resolution still completes in the background and notifies listeners, so the value self-corrects after a refresh. In-flight resolutions are de-duplicated, and completion is reported viaonDidChangeso the eventual interpreter propagates to Pylance without a server restart.activation/activationManager.ts– No longer blocks activation on auto-select; it races a short timeout. Auto-selection still runs exactly once and completes in the background.pythonEnvironments/.../conda.ts+pythonEnvironments/index.ts– AddConda.setSkipDeepProbe(true)when the environments extension owns discovery, so startup no longer triggers slow sequential registry /conda info --jsonprobes (the env extension / PET already discovers conda).python.condaPathremains an escape hatch.envExt/api.legacy.ts– De-duplicate in-flight active-interpreter resolutions and keep reporting changes viareportActiveInterpreterChanged.testing/testController/...– Defer project discovery and self-heal on environment change instead of throwingNo Python environment foundwhen an env hasn't been assigned yet during fast startup.Tests
Updated/added unit tests for
activationManager,interpreterService,conda, the legacy env API, and the test controller.Notes
This is part of a cross-repo effort to speed up Pylance startup (companion PRs in
vscode-python-environmentsand the Pylance server).