Skip to content

Commit

Permalink
Add timeout to python extension search
Browse files Browse the repository at this point in the history
Have only seen this happen once, so not merging into main yet unless it appears to be an actual issue
  • Loading branch information
will-v-pi committed Dec 19, 2024
1 parent 3e26da6 commit 85281a4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/utils/pythonHelper.mts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,24 @@ export default async function findPython(): Promise<string | undefined> {
}

// Check python extension for any python environments with version >= 3.9
pythonPath = await findPythonInPythonExtension();
const awaitFind = findPythonInPythonExtension();
// Timeout after 30s, as it can stall if there is no python available
const onTimeout = new Promise<string>((resolve) => {
setTimeout(resolve, 30000, "timeout");
});

await Promise.race([awaitFind, onTimeout]).then((value) => {
if (value === "timeout") {
Logger.warn(
LoggerSource.pythonHelper,
"Python Extension search timed out - attempting download instead"
);
pythonPath = undefined;
} else {
pythonPath = value;
}
});

if (pythonPath) {
await Settings.getInstance()?.updateGlobal(
SettingsKey.python3Path,
Expand Down

0 comments on commit 85281a4

Please sign in to comment.