Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureDeveloperCliCredential.get_token timed out with Python 3.12 on Ubuntu #2339

Open
hanohrs opened this issue Feb 8, 2025 · 0 comments
Open

Comments

@hanohrs
Copy link

hanohrs commented Feb 8, 2025

I know that this project only supports Python 3.9, 3.10, or 3.11, but I think it's worth sharing.

When I run scripts/prepdocs.sh with Python 3.12, I get the following error. (USE_LOCAL_PDF_PARSER="true")

[17:13:50] WARNING  AzureDeveloperCliCredential.get_token failed: Timed out waiting for Azure Developer CLI                                                                decorators.py:41
Traceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/subprocess.py", line 202, in communicate
    await self.wait()
  File "/usr/lib/python3.12/asyncio/subprocess.py", line 137, in wait
    return await self._transport._wait()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 230, in _wait
    return await waiter
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/identity/aio/_credentials/azd_cli.py", line 171, in _run_command
    stdout_b, stderr_b = await asyncio.wait_for(proc.communicate(), timeout)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
    async with timeouts.timeout(timeout):
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/hiro/repos/azure-search-openai-demo/./app/backend/prepdocs.py", line 439, in <module>
    loop.run_until_complete(main(ingestion_strategy, setup_index=not args.remove and not args.removeall))
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/./app/backend/prepdocs.py", line 244, in main
    await strategy.run()
  File "/home/hiro/repos/azure-search-openai-demo/app/backend/prepdocslib/filestrategy.py", line 103, in run
    blob_sas_uris = await self.blob_manager.upload_blob(file)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/app/backend/prepdocslib/blobmanager.py", line 52, in upload_blob
    if not await container_client.exists():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/tracing/decorator_async.py", line 94, in wrapper_use_tracer
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/storage/blob/aio/_container_client_async.py", line 547, in exists
    process_storage_error(error)
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/storage/blob/_shared/response_handlers.py", line 92, in process_storage_error
    raise storage_error
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/storage/blob/aio/_container_client_async.py", line 543, in exists
    await self._client.container.get_properties(**kwargs)
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/tracing/decorator_async.py", line 94, in wrapper_use_tracer
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/storage/blob/_generated/aio/operations/_container_operations.py", line 234, in get_properties
    pipeline_response: PipelineResponse = await self._client._pipeline.run(  # pylint: disable=protected-access
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_base_async.py", line 219, in run
    return await first_node.send(pipeline_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_base_async.py", line 68, in send
    response = await self.next.send(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_base_async.py", line 68, in send
    response = await self.next.send(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_base_async.py", line 68, in send
    response = await self.next.send(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 3 more times]
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/policies/_authentication_async.py", line 98, in send
    await await_result(self.on_request, request)
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_tools_async.py", line 56, in await_result
    return await result
           ^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/policies/_authentication_async.py", line 70, in on_request
    self._token = await await_result(self._credential.get_token, *self._scopes)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/core/pipeline/_tools_async.py", line 56, in await_result
    return await result
           ^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/identity/aio/_internal/decorators.py", line 21, in wrapper
    token = await fn(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/identity/aio/_credentials/azd_cli.py", line 130, in get_token
    output = await _run_command(command, self._process_timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hiro/repos/azure-search-openai-demo/.venv/lib/python3.12/site-packages/azure/identity/aio/_credentials/azd_cli.py", line 176, in _run_command
    raise CredentialUnavailableError(message="Timed out waiting for Azure Developer CLI") from ex
azure.identity._exceptions.CredentialUnavailableError: Timed out waiting for Azure Developer CLI

After I built Python 3.11 from the source and modify scripts/load_python_env.sh to use Python 3.11, it works fine.

Modifying .venv/lib/python3.12/site-packages/azure/identity/aio/_credentials/azd_cli.py to return _SyncAzureDeveloperCliCredential from get_token also fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant