Skip to content

Fast Pylance startup: don't block activation on environment enumeration - #26019

Merged
Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
rchiodo:rchiodo-fast-pylance-startup
Jun 24, 2026
Merged

Rich Chiodo (rchiodo) merged 2 commits into
microsoft:mainfrom
rchiodo:rchiodo-fast-pylance-startup

Conversation

@rchiodo

@rchiodo Rich Chiodo (rchiodo) commented Jun 24, 2026 •

Copy link
Copy Markdown

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 via onDidChange so 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 – Add Conda.setSkipDeepProbe(true) when the environments extension owns discovery, so startup no longer triggers slow sequential registry / conda info --json probes (the env extension / PET already discovers conda). python.condaPath remains an escape hatch.
  • envExt/api.legacy.ts – De-duplicate in-flight active-interpreter resolutions and keep reporting changes via reportActiveInterpreterChanged.
  • testing/testController/... – Defer project discovery and self-heal on environment change instead of throwing No Python environment found when 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-environments and the Pylance server).

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>
@rchiodo Rich Chiodo (rchiodo) added bug Issue identified by VS Code Team member as probable bug area-environments Features relating to handling interpreter environments labels Jun 24, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rchiodo
Rich Chiodo (rchiodo) enabled auto-merge (squash) June 24, 2026 22:15
@rchiodo
Rich Chiodo (rchiodo) merged commit d605c6d into microsoft:main Jun 24, 2026
49 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug

2 participants