diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a1c88e2..234a9ef 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +1.2.2 +----- + +* Fixed an example, that used deprecated `utcnow` + 1.2.1 ----- diff --git a/README.rst b/README.rst index 7f8f9e4..61579e7 100644 --- a/README.rst +++ b/README.rst @@ -460,7 +460,7 @@ a custom :class:`memoize.entrybuilder.CacheEntryBuilder`. class TtlRespectingCacheEntryBuilder(CacheEntryBuilder): def build(self, key: CacheKey, value: ValueWithTTL): - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc) ttl_ends_at = now + datetime.timedelta(seconds=value.ttl_seconds) return CacheEntry( created=now, diff --git a/examples/ttl/ttl_asyncio.py b/examples/ttl/ttl_asyncio.py index d7ed212..d6223bd 100644 --- a/examples/ttl/ttl_asyncio.py +++ b/examples/ttl/ttl_asyncio.py @@ -1,3 +1,7 @@ +# needed if one has tornado installed (could be removed otherwise) +from memoize import memoize_configuration +memoize_configuration.force_asyncio = True + import datetime import asyncio import random @@ -9,10 +13,6 @@ from memoize.entrybuilder import CacheEntryBuilder from memoize.storage import LocalInMemoryCacheStorage -# needed if one has tornado installed (could be removed otherwise) -from memoize import memoize_configuration -memoize_configuration.force_asyncio = True - @dataclass class ValueWithTTL: @@ -22,7 +22,7 @@ class ValueWithTTL: class TtlRespectingCacheEntryBuilder(CacheEntryBuilder): def build(self, key: CacheKey, value: ValueWithTTL): - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.timezone.utc) ttl_ends_at = now + datetime.timedelta(seconds=value.ttl_seconds) return CacheEntry( created=now, diff --git a/setup.py b/setup.py index 10d0da4..95517bd 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ def prepare_description(): setup( name='py-memoize', - version='1.2.1', + version='1.2.2', author='Michal Zmuda', author_email='zmu.michal@gmail.com', url='https://github.com/DreamLab/memoize',