Skip to content

Commit 64d181f

Browse files
committed
Merged PR posit-dev/positron-python#120: add a progress indicator and cancel button during ipykernel install
Merge pull request #120 from posit-dev/ipykernel-progress-and-cancel add a progress indicator and cancel button during ipykernel install -------------------- Commit message for posit-dev/positron-python@d8c04ec: add a progress indicator and cancel button during ipykernel install Authored-by: Wasim Lorgat <[email protected]> Signed-off-by: Wasim Lorgat <[email protected]>
1 parent fdb13b6 commit 64d181f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

extensions/positron-python/src/client/activation/jedi/pythonLanguageRuntime.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,14 @@ export class PythonLanguageRuntime implements JupyterLanguageRuntime, Disposable
112112
// Thow an error if it could not be installed.
113113
const hasKernel = await this.installer.isInstalled(Product.ipykernel, this.interpreter);
114114
if (!hasKernel) {
115+
// Pass a cancellation token to enable VSCode's progress indicator and let the user
116+
// cancel the install.
117+
const tokenSource = new vscode.CancellationTokenSource();
118+
const installerToken = tokenSource.token;
119+
115120
const response = await this.installer.promptToInstall(Product.ipykernel,
116-
this.interpreter, undefined, undefined, this.installOptions);
121+
this.interpreter, installerToken, undefined, this.installOptions);
122+
117123
switch (response) {
118124
case InstallerResponse.Installed:
119125
traceVerbose(`Successfully installed ipykernel for ${this.interpreter?.displayName}`);

extensions/positron-python/src/client/common/installer/moduleInstaller.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IApplicationShell } from '../application/types';
1414
import { wrapCancellationTokens } from '../cancellation';
1515
import { IFileSystem } from '../platform/types';
1616
import * as internalPython from '../process/internal/python';
17-
import { IProcessServiceFactory } from '../process/types';
17+
import { IProcessServiceFactory, SpawnOptions } from '../process/types';
1818
import { ITerminalServiceFactory, TerminalCreationOptions } from '../terminal/types';
1919
import { ExecutionInfo, IConfigurationService, ILogOutputChannel, Product } from '../types';
2020
import { isResource } from '../utils/misc';
@@ -31,7 +31,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
3131

3232
public abstract get type(): ModuleInstallerType;
3333

34-
constructor(protected serviceContainer: IServiceContainer) {}
34+
constructor(protected serviceContainer: IServiceContainer) { }
3535

3636
public async installModule(
3737
productOrModuleName: Product | string,
@@ -230,7 +230,12 @@ export abstract class ModuleInstaller implements IModuleInstaller {
230230
);
231231
await processService.shellExec(quoted);
232232
} else {
233-
await processService.exec(command, args);
233+
// --- Start Positron ---
234+
// Pass the cancellation token through so that users can cancel installs via the UI
235+
// when executeInTerminal is false
236+
const spawnOptions: SpawnOptions = { token };
237+
await processService.exec(command, args, spawnOptions);
238+
// --- End Positron ---
234239
}
235240
}
236241
}

0 commit comments

Comments
 (0)