Describe the bug
When running any az command (e.g. az login), two errors are printed to stderr on startup:
Error loading command module 'containerapp': 'msrest'
Error loading command module 'cdn': deadlock detected by _ModuleLock('msrest.http_logger') at <address>
Despite these errors, the affected commands (az containerapp, az cdn) still appear to load successfully and are usable. The errors are non-fatal but appear on every invocation.
Environment
|
|
| azure-cli version |
2.84.0 |
| Python version |
3.14.3 |
| Installation method |
pipx |
| OS |
macOS 15.7.4 (Sequoia), arm64 |
Steps to reproduce
- Install azure-cli via pipx on macOS arm64 with Python 3.14:
- Run any az command:
Expected behavior
No errors printed to stderr on startup. Command modules load silently.
Actual behavior
Two errors appear every invocation (address will vary):
Error loading command module 'containerapp': 'msrest'
Error loading command module 'cdn': deadlock detected by _ModuleLock('msrest.http_logger') at 4711984592
Root cause analysis
This appears to be a recurrence of the Python import-lock race condition fixed in PR #26287 (which addressed requests.models deadlocks in Python 3.10.10). The same multi-threaded command module loading in azure.cli.core triggers a _ModuleLock deadlock on msrest.http_logger when running under Python 3.14, and a KeyError: 'msrest' in the containerapp module (likely due to msrest being only partially initialized in one thread when another accesses it).
msrest is present and importable in the venv — single-threaded imports of both modules succeed without error. The failures are specific to the concurrent loading path.
References
Describe the bug
When running any
azcommand (e.g.az login), two errors are printed to stderr on startup:Despite these errors, the affected commands (
az containerapp,az cdn) still appear to load successfully and are usable. The errors are non-fatal but appear on every invocation.Environment
Steps to reproduce
Expected behavior
No errors printed to stderr on startup. Command modules load silently.
Actual behavior
Two errors appear every invocation (address will vary):
Root cause analysis
This appears to be a recurrence of the Python import-lock race condition fixed in PR #26287 (which addressed
requests.modelsdeadlocks in Python 3.10.10). The same multi-threaded command module loading inazure.cli.coretriggers a_ModuleLockdeadlock onmsrest.http_loggerwhen running under Python 3.14, and aKeyError: 'msrest'in thecontainerappmodule (likely due tomsrestbeing only partially initialized in one thread when another accesses it).msrestis present and importable in the venv — single-threaded imports of both modules succeed without error. The failures are specific to the concurrent loading path.References
aaz: Fix importlib deadlocks while loadingrequests.modelsin multi threads #26287: {Core} aaz: Fix importlib deadlocks while loading requests.models in multi threads