amazon-sqs-python-extended-client-lib icon indicating copy to clipboard operation
amazon-sqs-python-extended-client-lib copied to clipboard

Example code in README doesn't make sense

Open allanlewis opened this issue 11 months ago • 2 comments
trafficstars

The example code in the README doesn't make sense as it imports sqs_extended_client and then immediately overwrites that with the return value of boto3.client: https://github.com/awslabs/amazon-sqs-python-extended-client-lib/blob/9175bbd786ca197a4f4df57db52db89f89a65639/README.md#L47-L49

This makes it difficult to understand what's provided by this library and what is from normal boto3.

allanlewis avatar Dec 10 '24 16:12 allanlewis

I agree, this is an ill designed library

sevakram avatar Mar 06 '25 04:03 sevakram

Unfortunately this library uses implicit monkey patching, instead of providing simple wrapper or explicit monkey patch apply API. In README example by importing sqs_extended_client module we actually rewrite boto3.Session with SQSExtendedClientSession.

So example should look something like:

import boto3
import sqs_extended_client  # noqa: F401, monkeypatch

client = boto3.client("sqs", region_name="us-east-1")
client.large_payload_support = "BUCKET_NAME_HERE" 

Or in case you are using resource API:

import boto3
import sqs_extended_client  # noqa: F401, monkeypatch

sqs = boto3.resource("sqs")
sqs.meta.client.large_payload_support = "BUCKET_NAME_HERE" 

2tunnels avatar Mar 27 '25 20:03 2tunnels