Incompatible with Python 3.12
Closed this issue · 6 comments
I get this error:
File "/usr/local/lib/python3.12/site-packages/aws_secretsmanager_caching/cache/items.py", line 203, in _execute_refresh
self._next_refresh_time = datetime.utcnow() + timedelta(seconds=randint(round(ttl / 2), ttl))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/random.py", line 336, in randint
return self.randrange(a, b+1)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/random.py", line 312, in randrange
istop = _index(stop)
^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer
There is also a PR #30 from Sep 2022, to fix this which is not merged.
Hi andreas-wolf, thanks for the report. We are currently looking at several tickets related to Python 3.12 support across our libraries and will include this one.
Are there any plans on scheduling a release of a new version? I would love to be able to upgrade to Python 3.12 but this package is preventing me from doing so.
Are there any plans on scheduling a release of a new version? I would love to be able to upgrade to Python 3.12 but this package is preventing me from doing so.
I agree, a new release would save us all some headache, but in the mean time you can work around the issue like so:
secret_cache = SecretCache(config=SecretCacheConfig(secret_refresh_interval=3600))
I just ended up abandoning this package altogether and just using boto3, which seems to have better support from the AWS team.
import json
import boto3
client = boto3.client("secretsmanager")
secret_value = json.load(client.get_secret_value(SecretId=secret_identifier)["SecretString"])
This was enough for my use case and works in Python 3.12
import json import boto3 client = boto3.client("secretsmanager") secret_value = json.load(client.get_secret_value(SecretId=secret_identifier)["SecretString"])
This was enough for my use case and works in Python 3.12
I didn't even realize this was an option! thanks for the suggestion
I just ended up abandoning this package altogether and just using boto3, which seems to have better support from the AWS team.
import json import boto3 client = boto3.client("secretsmanager") secret_value = json.load(client.get_secret_value(SecretId=secret_identifier)["SecretString"])
This was enough for my use case and works in Python 3.12
If you don't need to cache the values (which essentially avoids hitting the secrets manager every time the application makes a request) you don't need to use this pacakge.
This package depends on botocore
which is a staple in the python/aws world. It is a shame that this hasn't been update for python 3.12