You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using python sdk how can we pass the retry parameter/argument in the poolmanager object? Say if the request takes a longer time than normal for whatever reason and so we would like to pass a retry number, can we utilize the retry class supported by urllib3? Appreciate your help.
Swagger-codegen version
2.2.3
Swagger declaration file content or url
The text was updated successfully, but these errors were encountered:
dnome2
changed the title
how can we utilize the retry mechanism for requests made via sdk.
[python] how can we utilize the retry mechanism for requests made via sdk.
Sep 15, 2017
@dnome2 You can access PoolManager through ApiClient.rest_client.pool_manager. If you want changes to apply to every client, you'd need to create ApiClient directly, making sure to pass it whenever you create a new client object.
Using pet store as an example:
When creating new client like PetApi, it creates its own instance of ApiClient unless you pass your own via the api_client kw (as PetApi.api_client)
ApiClient creates its own RESTClientObject (as ApiClient.rest_client)
RESTClientObject creates its own urllib3.PoolManager (as RESTClientObject.pool_manager)
So that's why you'd need to set all new clients to use that particular ApiClient instance- if you don't, they'll create their own with default settings. I guess that might be useful if you want different APIs to have different PoolManager settings or something.
Here's an example of how you'd set and make sure it applies to all the pet store's API clients:
I just tested it offline on my end and verified urllib3 made 10 attempts, while the default is 3
Sidenote/tangent: If that's annoying to do every time, and you don't mind editing the generated swagger_client library directly, you can sorta make this the default behavior by having ApiClient instantiate the clients on its own, passing self when it does. Quick dirty example, in ApiClient.__init__, you might do:
from .apis import PetApi
self.pet_api = PetApi(api_client=self)
That way you'd only need to create ApiClient and update the pool manager settings once, and could access the other clients through it like api_client.pet_api.find_pets_by_status('foo') and any changes you make via ApiClient later would be reflected in all the clients assigned to it. If you're creating multiple clients it also avoids the need to explicitly set the clients all over again for each one
Description
using python sdk how can we pass the retry parameter/argument in the poolmanager object? Say if the request takes a longer time than normal for whatever reason and so we would like to pass a retry number, can we utilize the retry class supported by urllib3? Appreciate your help.
Swagger-codegen version
2.2.3
Swagger declaration file content or url
The text was updated successfully, but these errors were encountered: