From e6701fe80a8e0095ed8d90afa20ecdd810471867 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Mon, 22 Jul 2024 08:57:12 -0700 Subject: [PATCH] Fix disposing native api --- src/client/pythonEnvironments/index.ts | 2 ++ src/client/pythonEnvironments/nativeAPI.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/index.ts b/src/client/pythonEnvironments/index.ts index 91064bb675991..373812b33061d 100644 --- a/src/client/pythonEnvironments/index.ts +++ b/src/client/pythonEnvironments/index.ts @@ -60,7 +60,9 @@ export async function initialize(ext: ExtensionState): Promise { if (shouldUseNativeLocator()) { const finder = getNativePythonFinder(); + ext.disposables.push(finder); const api = createNativeEnvironmentsApi(finder); + ext.disposables.push(api); registerNewDiscoveryForIOC( // These are what get wrapped in the legacy adapter. ext.legacyIOC.serviceManager, diff --git a/src/client/pythonEnvironments/nativeAPI.ts b/src/client/pythonEnvironments/nativeAPI.ts index 8f12addabfb4a..fef76987546a9 100644 --- a/src/client/pythonEnvironments/nativeAPI.ts +++ b/src/client/pythonEnvironments/nativeAPI.ts @@ -334,7 +334,7 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable { } } -export function createNativeEnvironmentsApi(finder: NativePythonFinder): IDiscoveryAPI { +export function createNativeEnvironmentsApi(finder: NativePythonFinder): IDiscoveryAPI & Disposable { const native = new NativePythonEnvironments(finder); native.triggerRefresh().ignoreErrors(); return native;