Title: Performance [P2]: Defer synchronous Azure token acquisition by berndverst · Pull Request #199 · microsoft/durabletask-python · GitHub
Open Graph Title: Performance [P2]: Defer synchronous Azure token acquisition by berndverst · Pull Request #199 · microsoft/durabletask-python
X Title: Performance [P2]: Defer synchronous Azure token acquisition by berndverst · Pull Request #199 · microsoft/durabletask-python
Description: Summary AccessTokenManager.__init__() acquired an Azure access token eagerly, so constructing a DurableTaskSchedulerClient or DurableTaskSchedulerWorker performed a blocking credential round trip to Entra before any RPC was made. DTSDefaultClientInterceptorImpl.__init__() then called get_access_token() immediately, so the cost was paid even for instances that were never used. SandboxWorker goes through the same construction path. Token acquisition is now deferred to the first intercepted RPC: AccessTokenManager.__init__() no longer calls credential.get_token(); it starts with _token = None / expiry_time = None. DTSDefaultClientInterceptorImpl.__init__() no longer primes the token or the authorization header. The existing double-checked refresh lock in get_access_token() is untouched, so the deferred first acquisition is still single-flight across threads, and refresh-before-expiry behavior is unchanged. _intercept_call() already upserted the authorization header on every call, so no header is missing on the first request. This mirrors what DTSAsyncDefaultClientInterceptorImpl already does. Behavior change (timing only) Credential failures — for example an unavailable managed identity or a misconfigured DefaultAzureCredential — now surface from the first request instead of from the constructor. The exception type and message are unchanged; only the timing differs. This is called out in durabletask-azuremanaged/CHANGELOG.md under ## Unreleased. No public API changed: no signature changes, no renames, no removed symbols, no changed import paths. No warm-up hook was added, to avoid expanding public surface — callers that want fail-fast authentication can call credential.get_token(...) themselves before constructing a client or worker. Tests tests/durabletask-azuremanaged/test_durabletask_grpc_interceptor.py: Added test_client_construction_does_not_acquire_token — asserts zero credential calls at client construction, exactly one on the first RPC, that the authorization header is present on that request, and that a second request reuses the cached token. Added test_worker_construction_does_not_acquire_token — asserts zero credential calls at worker construction. Added test_deferred_first_acquisition_performs_single_acquisition — 8 concurrent threads on a freshly constructed manager result in exactly one credential call, proving the deferred first acquisition is single-flight. Reworked test_concurrent_refresh_performs_single_refresh — the single-flight-on-expiry assertion is preserved, with the token now primed explicitly instead of relying on constructor acquisition. All three new tests were verified to fail against the unfixed source and pass with the fix. Verification Provider unit tests: pytest tests/durabletask-azuremanaged/test_durabletask_grpc_interceptor.py tests/durabletask-azuremanaged/test_sandboxes_extension.py -q -> 45 passed (baseline 42; +3 new). Core unit tests: pytest tests/durabletask -q --ignore-glob="*_e2e.py" -> 681 passed, 7 skipped. Baseline on this branch had 1 failure in the timing-sensitive test_sync_client_recreate_cooldown_prevents_immediate_repeated_recreation, which is flaky/environmental and passes here. flake8 clean on all four changed files. pyright (repo pyrightconfig.json, strict): 0 diagnostics in the changed source files. pymarkdown -c .pymarkdown.json scan durabletask-azuremanaged/CHANGELOG.md: the two MD013 line-length findings are pre-existing on untouched lines; the added lines introduce none. Scope was kept strictly to this issue — no changes related to #192 (async single-flight refresh) or #195 (SDK version lookup caching), which live in the same files. Fixes #187
Open Graph Description: Summary AccessTokenManager.__init__() acquired an Azure access token eagerly, so constructing a DurableTaskSchedulerClient or DurableTaskSchedulerWorker performed a blocking credential round trip t...
X Description: Summary AccessTokenManager.__init__() acquired an Azure access token eagerly, so constructing a DurableTaskSchedulerClient or DurableTaskSchedulerWorker performed a blocking credential round trip t...
Opengraph URL: https://github.com/microsoft/durabletask-python/pull/199
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:39203653-4f34-5ae9-49f3-acd2323f2270 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9FE2:29F3CB:14E648:1B3792:6AFE44BC |
| html-safe-nonce | 368f6076f11369f5c1addff1ee16bfe4cc66c54539dce1eabfbb097f7ddaf788 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkUyOjI5RjNDQjoxNEU2NDg6MUIzNzkyOjZBRkU0NEJDIiwidmlzaXRvcl9pZCI6IjgyMzM4OTU5MTM5MjQyMTU5OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ebfcd08c2f888ce201e44c88510ca490797e32b2ef1d405d1ea8248858ac85e7 |
| hovercard-subject-tag | pull_request:4139759119 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/199/files |
| twitter:image | https://avatars.githubusercontent.com/u/4535280?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4535280?s=400&v=4 |
| og:image:alt | Summary AccessTokenManager.__init__() acquired an Azure access token eagerly, so constructing a DurableTaskSchedulerClient or DurableTaskSchedulerWorker performed a blocking credential round trip t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 627664515 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627664515 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ce393ea11ad276623b946bc9663d3e7d6f564275 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width