Under concurrency (e.g. asyncio.gather), token acquisition fails with errors such as “HTTP transport has already been closed” / “Session closed”. Example:
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
import asyncio
credential = ClientSecretCredential(...)
client = GraphServiceClient(
credentials=credential,
scopes=["https://graph.microsoft.com/.default"],
)
async def fetch_users():
await client.users.get()
async def main():
await asyncio.gather(*[fetch_users() for i in range(5)])
if __name__ == "__main__":
asyncio.run(main())
I guess the lifecycle of credentials object belongs to the app and we shouldn't implicitly close the transport. Suggested fix is to remove this line.
Under concurrency (e.g.
asyncio.gather), token acquisition fails with errors such as “HTTP transport has already been closed” / “Session closed”. Example:I guess the lifecycle of credentials object belongs to the app and we shouldn't implicitly close the transport. Suggested fix is to remove this line.