Repository navigation
How do I set the request timeout for the GraphServiceClient? #742
Replies: 3 comments
|
bump |
|
And: https://www.python-httpx.org/advanced/timeouts/ Create an |
|
You can configure the timeout by providing a custom "httpx.AsyncClient" to the "GraphRequestAdapter". The "GraphServiceClient" accepts a custom request adapter, so you don't need to modify the SDK itself. Here's a working example: import httpx Configure your desired timeout in secondshttp_client = httpx.AsyncClient( Apply the default Microsoft Graph middlewarehttp_client = GraphClientFactory.create_with_default_middleware( Reuse your existing authentication providerrequest_adapter = GraphRequestAdapter( client = GraphServiceClient( Here, "auth_provider" is the authentication provider you already use with your Graph client. You can also configure different timeout values for connection, read, write, and connection-pool operations: timeout = httpx.Timeout( Then pass "timeout=timeout" to "httpx.AsyncClient()". This works because the Graph SDK uses HTTPX underneath, and the custom HTTP client is passed through the request adapter. The default Graph middleware is preserved using "GraphClientFactory.create_with_default_middleware()". Official documentation: |
Uh oh!
There was an error while loading. Please reload this page.
I found this: https://stackoverflow.com/questions/43260659/set-timeout-to-a-higher-value-in-microsoft-graph-sdk
but the http provider doesn't appear to be present in the object. I can't seem to find the docs on how to set this either.
All reactions