Skip to content

Commit

Permalink
Use throttled_http_client
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed Aug 19, 2021
1 parent b3098e8 commit e538b02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .token_cache import TokenCache
import msal.telemetry
from .region import _detect_region
from .throttled_http_client import ThrottledHttpClient


# The __init__.py will import this. Not the other way around.
Expand Down Expand Up @@ -336,6 +337,10 @@ def __init__(
a = requests.adapters.HTTPAdapter(max_retries=1)
self.http_client.mount("http://", a)
self.http_client.mount("https://", a)
self.http_client = ThrottledHttpClient(
self.http_client,
{} # Hard code an in-memory cache, for now
)

self.app_name = app_name
self.app_version = app_version
Expand Down Expand Up @@ -433,6 +438,7 @@ def _build_client(self, client_credential, authority, skip_regional_client=False
"x-client-sku": "MSAL.Python", "x-client-ver": __version__,
"x-client-os": sys.platform,
"x-client-cpu": "x64" if sys.maxsize > 2 ** 32 else "x86",
"x-ms-lib-capability": "retry-after, h429",
}
if self.app_name:
default_headers['x-app-name'] = self.app_name
Expand Down

0 comments on commit e538b02

Please sign in to comment.