From 297fa2ac62f5ca7864b2c54f334e5a389f9f6c9e Mon Sep 17 00:00:00 2001 From: Rich Chiodo Date: Fri, 4 Oct 2019 10:16:44 -0700 Subject: [PATCH] Fix jupyter server startup hang when xeus-cling is installed --- news/2 Fixes/7569.md | 1 + src/client/common/process/pythonProcess.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 news/2 Fixes/7569.md diff --git a/news/2 Fixes/7569.md b/news/2 Fixes/7569.md new file mode 100644 index 000000000000..20e5e8a45853 --- /dev/null +++ b/news/2 Fixes/7569.md @@ -0,0 +1 @@ +Fix jupyter server startup hang when xeus-cling kernel is installed. diff --git a/src/client/common/process/pythonProcess.ts b/src/client/common/process/pythonProcess.ts index 6030df4a6e11..9d7d15333768 100644 --- a/src/client/common/process/pythonProcess.ts +++ b/src/client/common/process/pythonProcess.ts @@ -1,17 +1,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. - import { injectable } from 'inversify'; import * as path from 'path'; + import { IServiceContainer } from '../../ioc/types'; import { EXTENSION_ROOT_DIR } from '../constants'; import { ErrorUtils } from '../errors/errorUtils'; import { ModuleNotInstalledError } from '../errors/moduleNotInstalledError'; import { traceError } from '../logger'; import { IFileSystem } from '../platform/types'; +import { waitForPromise } from '../utils/async'; import { Architecture } from '../utils/platform'; import { parsePythonVersion } from '../utils/version'; -import { ExecutionResult, InterpreterInfomation, IProcessService, IPythonExecutionService, ObservableExecutionResult, PythonVersionInfo, SpawnOptions } from './types'; +import { + ExecutionResult, + InterpreterInfomation, + IProcessService, + IPythonExecutionService, + ObservableExecutionResult, + PythonVersionInfo, + SpawnOptions +} from './types'; @injectable() export class PythonExecutionService implements IPythonExecutionService { @@ -28,8 +37,12 @@ export class PythonExecutionService implements IPythonExecutionService { public async getInterpreterInformation(): Promise { const file = path.join(EXTENSION_ROOT_DIR, 'pythonFiles', 'interpreterInfo.py'); try { - const jsonValue = await this.procService.exec(this.pythonPath, [file], { mergeStdOutErr: true }) - .then(output => output.stdout.trim()); + // Sometimes the python path isn't valid, timeout if that's the case. + // See these two bugs: + // https://github.com/microsoft/vscode-python/issues/7569 + // https://github.com/microsoft/vscode-python/issues/7760 + const jsonValue = await waitForPromise(this.procService.exec(this.pythonPath, [file], { mergeStdOutErr: true }), 5000) + .then(output => output ? output.stdout.trim() : '--timed out--'); // --timed out-- should cause an exception let json: { versionInfo: PythonVersionInfo; sysPrefix: string; sysVersion: string; is64Bit: boolean }; try {