forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreWarmVariables.ts
More file actions
35 lines (31 loc) · 1.54 KB
/
preWarmVariables.ts
File metadata and controls
35 lines (31 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable } from 'inversify';
import { IExtensionSingleActivationService } from '../activation/types';
import '../common/extensions';
import { IDisposableRegistry } from '../common/types';
import { noop } from '../common/utils/misc';
import { IEnvironmentActivationService } from '../interpreter/activation/types';
import { JupyterInterpreterService } from './jupyter/interpreter/jupyterInterpreterService';
@injectable()
export class PreWarmActivatedJupyterEnvironmentVariables implements IExtensionSingleActivationService {
constructor(
@inject(IEnvironmentActivationService) private readonly activationService: IEnvironmentActivationService,
@inject(JupyterInterpreterService) private readonly jupyterInterpreterService: JupyterInterpreterService,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry
) {}
public async activate(): Promise<void> {
this.disposables.push(
this.jupyterInterpreterService.onDidChangeInterpreter(() => this.preWarmInterpreterVariables().catch(noop))
);
this.preWarmInterpreterVariables().ignoreErrors();
}
private async preWarmInterpreterVariables() {
const interpreter = await this.jupyterInterpreterService.getSelectedInterpreter();
if (!interpreter) {
return;
}
this.activationService.getActivatedEnvironmentVariables(undefined, interpreter).ignoreErrors();
}
}