Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

Hanging `python.exe` threads when running any az cli commands #29089

Open ecm200 opened 5 months ago

ecm200 commented 5 months ago

Describe the bug

In a Microsoft Terminal Powershell, I run any azure cli command, this completes successfully. However, the python.exe process which ran when the command was issued remains, using up a full single core. This continues with each additional execution of the az cli, with the number of python.exe equal to the number az cli calls made.

For example, calling az --version 3 times, results in 3 python.exe processes remaining, with full single core cpu demands. Each call completes successfully

image

Even after closing the terminal session, the processes remain:

image

The processes can be killed through Task Manager, but will remain taking up significant system resource if not killed.

Related command

Tested with any call to the azure cli az tools.

Errors

There are no error messages, just hanging processes.

Issue script & Debug output

There is no bug or error report.

Expected behavior

The expected behaviour would be the python.exe threads terminating on the successful completion of the az cli command.

Environment Summary

azure-cli 2.60.0 *

core 2.60.0 * telemetry 1.1.0

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\ed.morris.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 21:52:07) [MSC v.1937 32 bit (Intel)]

Additional context

No response

azure-client-tools-bot-prd[bot] commented 5 months ago

Hi @ecm200,

2.60.0 is not the latest Azure CLI(2.61.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

yonzhan commented 5 months ago

Thank you for opening this issue, we will look into it.

ecm200 commented 5 months ago

I have upgraded to version 2.61.0 and this has not changed the behaviour, python.exe threads are still left hanging using a full single thread of cpu until they are manually terminated.

ecm200 commented 5 months ago

image

image

bebound commented 5 months ago

Please run az config set core.collect_telemetry=false and verify if the issue persists.

ecm200 commented 5 months ago

Please run az config set core.collect_telemetry=false and verify if the issue persists.

@bebound , I did as you suggested, and I can confirm that this setting has resulted in a solution to the issue. That is, the python.exe thread is no longer left hanging when the core.collect_telemetry=false flag is set.

Turning it back on, that is core.collect_telemetry=true, causes the return of the previous of behaviour.

bebound commented 5 months ago

@evelyn-ys for awareness. The telemetry uploading process hangs.

evelyn-ys commented 5 months ago

@ecm200 Can you kindly share your telemetry log file with us? It locates in $HOME/.azure/logs/telemetry.log

If it contains private data which you don't want to put in github, feel free to email our team AzPyCLI@microsoft.com