@@ -9,26 +9,31 @@ import { getRegistryInterpreters } from '../../../common/windowsUtils';
9
9
import { traceError , traceVerbose } from '../../../../logging' ;
10
10
import { isMicrosoftStoreDir } from '../../../common/environmentManagers/microsoftStoreEnv' ;
11
11
import { PythonEnvsChangedEvent } from '../../watcher' ;
12
+ import { DiscoveryUsingWorkers } from '../../../../common/experiments/groups' ;
13
+ import { inExperiment } from '../../../common/externalDependencies' ;
12
14
13
15
export const WINDOWS_REG_PROVIDER_ID = 'windows-registry' ;
14
16
15
17
export class WindowsRegistryLocator extends Locator < BasicEnvInfo > {
16
18
public readonly providerId : string = WINDOWS_REG_PROVIDER_ID ;
17
19
18
20
// eslint-disable-next-line class-methods-use-this
19
- public iterEnvs ( query ?: PythonLocatorQuery , useWorkerThreads = false ) : IPythonEnvsIterator < BasicEnvInfo > {
21
+ public iterEnvs (
22
+ query ?: PythonLocatorQuery ,
23
+ useWorkerThreads = inExperiment ( DiscoveryUsingWorkers . experiment ) ,
24
+ ) : IPythonEnvsIterator < BasicEnvInfo > {
20
25
if ( useWorkerThreads ) {
21
26
/**
22
27
* Windows registry is slow and often not necessary, so notify completion immediately, but use watcher
23
28
* change events to signal for any new envs which are found.
24
29
*/
25
30
if ( query ?. providerId === this . providerId ) {
26
31
// Query via change event, so iterate all envs.
27
- return iterateEnvs ( true ) ;
32
+ return iterateEnvs ( ) ;
28
33
}
29
34
return iterateEnvsLazily ( this . emitter ) ;
30
35
}
31
- return iterateEnvs ( false ) ;
36
+ return iterateEnvs ( ) ;
32
37
}
33
38
}
34
39
@@ -38,13 +43,13 @@ async function* iterateEnvsLazily(changed: IEmitter<PythonEnvsChangedEvent>): IP
38
43
39
44
async function loadAllEnvs ( changed : IEmitter < PythonEnvsChangedEvent > ) {
40
45
traceVerbose ( 'Searching for windows registry interpreters' ) ;
41
- await getRegistryInterpreters ( true ) ;
46
+ await getRegistryInterpreters ( ) ;
42
47
changed . fire ( { providerId : WINDOWS_REG_PROVIDER_ID } ) ;
43
48
traceVerbose ( 'Finished searching for windows registry interpreters' ) ;
44
49
}
45
50
46
- async function * iterateEnvs ( useWorkerThreads : boolean ) : IPythonEnvsIterator < BasicEnvInfo > {
47
- const interpreters = await getRegistryInterpreters ( useWorkerThreads ) ;
51
+ async function * iterateEnvs ( ) : IPythonEnvsIterator < BasicEnvInfo > {
52
+ const interpreters = await getRegistryInterpreters ( ) ; // Value should already be loaded at this point, so this returns immediately.
48
53
for ( const interpreter of interpreters ) {
49
54
try {
50
55
// Filter out Microsoft Store app directories. We have a store app locator that handles this.
0 commit comments