Repository navigation
Python commands are printed twice in the output channel #7160
Copy link
Copy link
Closed
Labels
area-editor-*User-facing catch-allUser-facing catch-allbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded
Milestone
Description
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:
- Start debugging the extension
- Open a python file and enable linting or formatting on save
- Set 2 breakpoints:
const argsList = args.reduce((accumulator, current, index) => { this.emit('exec', file, args, options);
- Save the file
- 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
createorcreateActivatedEnvironmentmethod inPythonExecutionFactory:
vscode-python/src/client/common/process/pythonExecutionFactory.ts
Lines 31 to 37 in 39cf9e0
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:
vscode-python/src/client/common/process/processFactory.ts
Lines 21 to 26 in 39cf9e0
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)); }
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-editor-*User-facing catch-allUser-facing catch-allbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded
Activity
kbd commentedon Jul 20, 2021
As an easy-to-reproduce example of this, when I use "Format Document", the Python output log appears to show that Black is run twice:
DanielNoord commentedon Aug 5, 2021
Is there anything we can provide to get this issue some traction? I am mainly interested in whether commands are actually ran twice (which it seems it does). I'll gladly perform any tests or work with somebody to get this issue fixed!
kimadeline commentedon Aug 9, 2021
Hi Daniël van Noord (@DanielNoord), if this issue gets more upvotes it'll help us prioritize it.
They are not, it is just the logger being called twice.
karrtikr commentedon Oct 25, 2021
Verification steps:
Python: Switch to Insiderscommand.python -m venv .venvand select it as a interpreter usingPython: Select Interpretercommand.Format documenton a python file.only appears once in the output panel.
DanielNoord commentedon Oct 25, 2021
Kartik Raj (@karrtikr) Does this mean this was not fixed? Or is this just a reproduction for future reference?
karrtikr commentedon Oct 25, 2021
This was fixed by me, but it has to be verified by someone else (in the team or by the users) before we consider it as done, which is why I left the steps. You're welcome to test it as well.
rchiodo commentedon Oct 27, 2021
Kartik Raj (@karrtikr), Not sure if this is working or not?
I get this:
Looks like it logs twice?
karrtikr commentedon Oct 27, 2021
Can you turn off verbose logging and see if it logs twice? Verbose can log anything.
rchiodo commentedon Oct 27, 2021
Yep that was it. Only logs once without verbose.