You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 20c1381
Browse filesBrowse the repository at this point in the historyBrowse files
fix: clean up inline-script environments after activation (#1794)
## Summary
Inline-script cache cleanup previously ran before the first environment
creation in a window. Users who did not create another environment could
keep old cached environments indefinitely, and cleanup could delay
unrelated interpreter lookups.
- Run one delayed activation sweep instead of triggering cleanup from
`create()`. Keep the existing 14-day expiration policy, reclaim
incomplete setups after a one-day grace period, and remove at most three
entries per sweep. There is no daily sweep.
- Keep candidate scans and cleanup-result publication outside the
interpreter-lookup barrier. Retain per-entry locks, physical-path
ownership checks, reference checks, and an under-lock age recheck before
deletion.
- Refresh cached environments' last-used timestamps on lookup. Keep
optional bookkeeping off the critical path, use fail-fast read-path
metadata writes, and withhold an old entry when its protection cannot be
established rather than return an unsafe last-known descriptor.
- Preserve the selected interpreter through temporary unavailability,
expose setup for an explicit retry, and publish recovery events after
bounded background revalidation.
- Preserve retry deadlines and budgets across saves that leave the
inline requirements unchanged. Cancel stale recovery when requirements
or the stored association change, and recheck selection after
asynchronous timestamp work.
- Recover dead-owner cache locks and reconcile the environment catalog
after deletion without discarding a replacement rebuilt at the same
path.
- Add regression coverage and document the cleanup and recovery
behavior.
The feature remains behind the existing
`python-envs.inlineScripts.enabled` flag. This does not add a worker
process, recurring cleanup, dependencies, or a new cache format.
## Validation
Lint, type checking, the full unit suite, and the production bundle were
repeated after integrating the latest `main` API-facade refactor and
resolving the import in the relocated `src/extensionApi.ts`. Obsolete
compiled files from the renamed modules were removed before
recompilation. Cache-deletion, save/recovery, and ordinary-API scenarios
were also rerun against the integrated implementation.
- `npm run lint`
- `npm run compile-tests`
- `npm run unittest -- --reporter=dot --no-colors`: 2,409 passing, 6
pending.
- Production webpack bundle.
- Independent Windows walkthroughs using real Python virtual
environments, cache metadata, and entry locks:
- The actual 96-126 second activation timer removed an old orphan
without calling the manager's `create()` and did not schedule another
sweep.
- Exactly three old orphaned entries were removed; referenced, recent,
live-locked, newer-schema, and redirected entries were preserved.
- A normal project `.venv` and the base Python installation remained
usable.
- Another window's use after eviction planning prevented deletion.
- Temporary write failures and locks recovered with and without an
intervening same-requirements save.
- A pending timestamp write did not return a subsequently unset
interpreter.
- A healthy lookup completed while an unrelated cache inspection was
deliberately paused.
- HEAD/current shared-API comparisons retained ordinary-manager routing,
venv/conda timeout fallbacks, explicit non-inline overrides, and
neighboring-file isolation.
The walkthroughs adapt the editor/discovery-service boundaries; they are
not full live VS Code/Pylance GUI or macOS/Linux validation. Usage
timestamps are not process-lifetime leases.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/managing-python-projects.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,10 @@ Stop runs or debug sessions using the environment before deleting it. The extens
113
113
114
114
On Windows, changing only the letter casing of a script's filename keeps its existing environment association. A rename does not validate unsaved dependency edits or install packages.
115
115
116
+
Unused cached script environments are cleaned up once per window, about two minutes after the extension activates, rather than being triggered by environment creation. Cleanup considers entries unused for more than 14 days and incomplete setups older than one day, removes at most three entries, and skips environments referenced by this workspace or entries it cannot safely inspect. There is no daily sweep.
117
+
118
+
The background cache scan does not hold up interpreter lookups. If another window briefly locks an entry, or its last-used time cannot be updated safely, the extension retries the script association in the background with bounded delays. Saving without changing the inline requirements does not cancel, postpone, or reset those retries; changing the requirements or stored inline-environment association cancels outdated recovery work. A temporarily unavailable selected environment keeps its association instead of silently switching execution to another interpreter, and the setup action is available for an explicit retry. If automatic recovery does not succeed, use that action to retry. Cleanup never installs packages.
119
+
116
120
## Assigning Environments to Projects
117
121
118
122
Each project can have its own Python environment. This is the core benefit of project management.
0 commit comments