Change client config without creating a new client? #3725
Answered
by
tim-finnigan
softloft38p-michael
asked this question in
Q&A
|
Is there a way to change an option in an client config after creating a client? I would like to do something like this: kwargs = {}
client = boto3.client('s3', **kwargs)
# ...
supports_acceleration = bucket_supports_accelerated_transfer(bucket, client=client, **kwargs)
wanted_acceleration = False if not client.meta.config.s3 else client.meta.config.s3.get('use_accelerate_endpoint', False)
s3_config = getattr(client.meta.config, 's3', {})
if not supports_acceleration and wanted_acceleration:
s3_config["use_accelerate_endpoint"] = False
client.meta.config.s3 = s3_configCurrently I create a client, check if the bucket supports acceleration and then create a new client if the original one asked for acceleration, but the bucket doesn't support it. If I use the above approach of just changing the value in the original client config it doesn't update the client object so it continues to use acceleration after I change the setting. |
Answered by
tim-finnigan
Jun 6, 2023
Replies: 1 comment
|
You can't change the client after creating it but you create a Session to store configuration state and then create clients off of that. |
0 replies
Answer selected by
RyanFitzSimmonsAK
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't change the client after creating it but you create a Session to store configuration state and then create clients off of that.