@@ -149,6 +149,7 @@ export class PythonEnvironmentManager extends DisposableContext {
149149 private envChangeEmitter : vscode . EventEmitter < void > ;
150150 private displayedSDKError : boolean = false ;
151151 private lastLoadedEnv : string | undefined = undefined ;
152+ private activeSDK : SDK | undefined = undefined ;
152153
153154 constructor ( logger : Logger , reporter : TelemetryReporter ) {
154155 super ( ) ;
@@ -178,8 +179,8 @@ export class PythonEnvironmentManager extends DisposableContext {
178179 }
179180 }
180181
181- /// Load the active SDK from the currently active Python environment, or undefined if one is not present.
182- public async getActiveSDK ( ) : Promise < SDK | undefined > {
182+ /// Finds the active SDK from the currently active Python environment, or undefined if one is not present.
183+ public async findActiveSDK ( ) : Promise < SDK | undefined > {
183184 assert ( this . api !== undefined ) ;
184185 // Prioritize retrieving a monorepo SDK over querying the environment.
185186 const monorepoSDK = await this . tryGetMonorepoSDK ( ) ;
@@ -227,6 +228,15 @@ export class PythonEnvironmentManager extends DisposableContext {
227228 }
228229 }
229230
231+ /// Load the active SDK from the currently active Python environment, or undefined if one is not present.
232+ public async getActiveSDK ( ) : Promise < SDK | undefined > {
233+ if ( this . activeSDK ) {
234+ return this . activeSDK ;
235+ }
236+ this . activeSDK = await this . findActiveSDK ( ) ;
237+ return this . activeSDK ;
238+ }
239+
230240 private async displaySDKError ( message : string ) {
231241 if ( this . displayedSDKError ) {
232242 return ;
0 commit comments