Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/features/pythonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import { runInBackground } from './execution/runInBackground';
import { EnvVarManager } from './execution/envVariableManager';
import { checkUri } from '../common/utils/pathUtils';
import { waitForAllEnvManagers, waitForEnvManager, waitForEnvManagerId } from './common/managerReady';
import { timeout } from '../common/utils/asyncUtils';
import { isWindows } from '../common/utils/platformUtils';

class PythonEnvironmentApiImpl implements PythonEnvironmentApi {
private readonly _onDidChangeEnvironments = new EventEmitter<DidChangeEnvironmentsEventArgs>();
Expand Down Expand Up @@ -304,6 +306,12 @@ class PythonEnvironmentApiImpl implements PythonEnvironmentApi {
options.cwd instanceof Uri ? options.cwd : Uri.file(options.cwd),
environment,
);
if (isWindows()) {
// Since we have extra polliing on Windows that could lead to race stale promptInputModel value,
// temporarily add small timeout to avoid ^C.
// TODO: Consider removing when we clean up polling with newer conpty: https://github.com/microsoft/vscode/issues/224488
await timeout(50);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A timeout like this will always be flaky unfortunately.

Have you considered awaiting the activate call if triggered via executeCommand, and queuing any further commands until that resolves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar We actually do await for the activate call when activating with executeCommand

const terminal = await this.terminalManager.getProjectTerminal(
options.cwd instanceof Uri ? options.cwd : Uri.file(options.cwd),
environment,
);
await runInTerminal(environment, terminal, options);

which goes to:

Maybe the better fix is to move where https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts#L213 happens, to after execution in core?

}
await runInTerminal(environment, terminal, options);
return terminal;
}
Expand Down