microsoftgraph / msgraph-sdk-python

MIT License
388 stars 56 forks source link

The first request is very slow #909

Open michaelmesser opened 1 month ago

michaelmesser commented 1 month ago

Not sure if performance is a feature request or bug.

import win32gui
from azure.identity.broker import InteractiveBrowserBrokerCredential
from msgraph.graph_service_client import GraphServiceClient

1.1s (Already in issue #904)

current_window_handle = win32gui.GetForegroundWindow()
credentials = InteractiveBrowserBrokerCredential(
    tenant_id=tenant,
    client_id=client_id,
    use_default_broker_account=True,
    parent_window_handle=current_window_handle,
)

0.0s (Expected)

client = GraphServiceClient(
    credentials=credentials,
    scopes=[]
)

0.4s (Slower than I would expect)

await client.me.get()

2.2s (1st request. This is significantly slower than I would expect)

await client.me.get()

0.1s (2nd request. Expected)