Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly continue execution after timeout on launching conda binary is reached #22072

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/client/pythonEnvironments/common/environmentManagers/conda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { traceError, traceVerbose } from '../../../logging';
import { OUTPUT_MARKER_SCRIPT } from '../../../common/process/internal/scripts';
import { splitLines } from '../../../common/stringUtils';
import { SpawnOptions } from '../../../common/process/types';
import { sleep } from '../../../common/utils/async';

export const AnacondaCompanyName = 'Anaconda, Inc.';
export const CONDAPATH_SETTING_KEY = 'condaPath';
Expand Down Expand Up @@ -238,7 +239,7 @@ export function getCondaInterpreterPath(condaEnvironmentPath: string): string {
// Minimum version number of conda required to be able to use 'conda run' with '--no-capture-output' flag.
export const CONDA_RUN_VERSION = '4.9.0';
export const CONDA_ACTIVATION_TIMEOUT = 45000;
const CONDA_GENERAL_TIMEOUT = 50000;
const CONDA_GENERAL_TIMEOUT = 45000;

/** Wraps the "conda" utility, and exposes its functionality.
*/
Expand Down Expand Up @@ -439,9 +440,19 @@ export class Conda {
if (shellPath) {
options.shell = shellPath;
}
const result = await exec(command, ['info', '--json'], options);
traceVerbose(`${command} info --json: ${result.stdout}`);
return JSON.parse(result.stdout);
const resultPromise = exec(command, ['info', '--json'], options);
// It has been observed that specifying a timeout is still not reliable to terminate the Conda process, see #27915.
// Hence explicitly continue execution after timeout has been reached.
const success = await Promise.race([
resultPromise.then(() => true),
sleep(CONDA_GENERAL_TIMEOUT + 3000).then(() => false),
]);
if (success) {
const result = await resultPromise;
traceVerbose(`${command} info --json: ${result.stdout}`);
return JSON.parse(result.stdout);
}
throw new Error(`Launching '${command} info --json' timed out`);
}

/**
Expand Down
Loading