Skip to content

Python commands are printed twice in the output channel #7160

Closed
@kimadeline

Description

@kimadeline

Environment data

  • VS Code version: 1.37.1
  • Extension version (available under the Extensions sidebar): master 39cf9e0
  • OS and version: macOS Mojave 10.14.6

Expected behaviour

Python commands should only be displayed once in the "Python" output channel.

Actual behaviour

Some Python commands (for example linting or formatting) are displayed twice.

Steps to reproduce:

  1. Start debugging the extension
  2. Open a python file and enable linting or formatting on save
  3. Set 2 breakpoints:
  4. Save the file
  5. Notice that this.emit('exec', file, args, options); is only hit once, but the debugger stops twice onlogger.logProcess().

Cause

We register 2 'exec' listeners to the python process:

  • In the create or createActivatedEnvironment method in PythonExecutionFactory:
    public async create(options: ExecutionFactoryCreationOptions): Promise<IPythonExecutionService> {
    const pythonPath = options.pythonPath ? options.pythonPath : this.configService.getSettings(options.resource).pythonPath;
    const processService: IProcessService = await this.processServiceFactory.create(options.resource);
    const processLogger = this.serviceContainer.get<IProcessLogger>(IProcessLogger);
    processService.on('exec', processLogger.logProcess.bind(processLogger));
    return new PythonExecutionService(this.serviceContainer, processService, pythonPath);
    }
  • But also in the call to await this.processServiceFactory.create:
    public async create(resource?: Uri): Promise<IProcessService> {
    const customEnvVars = await this.envVarsService.getEnvironmentVariables(resource);
    const proc: IProcessService = new ProcessService(this.decoder, customEnvVars);
    this.disposableRegistry.push(proc);
    return proc.on('exec', this.processLogger.logProcess.bind(this.processLogger));
    }

Metadata

Metadata

Assignees

Labels

area-editor-*User-facing catch-allbugIssue identified by VS Code Team member as probable buggood first issueverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions