Skip to content

Commit 05c62a4

Browse files
fix: address review feedback for S3 store
- Add explicit client cleanup (set _client = None after __aexit__) - Remove deletion of expired objects during retrieval - Update both __aexit__ and _close for consistency Co-authored-by: William Easton <strawgate@users.noreply.github.com>
1 parent 042d855 commit 05c62a4

File tree

1 file changed

+3
-2
lines changed
  • key-value/key-value-aio/src/key_value/aio/stores/s3

1 file changed

+3
-2
lines changed

key-value/key-value-aio/src/key_value/aio/stores/s3/store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ async def __aexit__(
164164
await super().__aexit__(exc_type, exc_value, traceback)
165165
if self._client and self._raw_client:
166166
await self._client.__aexit__(exc_type, exc_value, traceback)
167+
self._client = None
167168

168169
@property
169170
def _connected_client(self) -> S3Client:
@@ -261,8 +262,7 @@ async def _get_managed_entry(self, *, key: str, collection: str) -> ManagedEntry
261262

262263
# Check for client-side expiration
263264
if managed_entry.is_expired:
264-
# Entry expired, delete it and return None
265-
await self._delete_managed_entry(key=key, collection=collection)
265+
# Entry expired, return None without deleting
266266
return None
267267
return managed_entry # noqa: TRY300
268268

@@ -353,3 +353,4 @@ async def _close(self) -> None:
353353
"""Close the S3 client."""
354354
if self._client and self._raw_client:
355355
await self._client.__aexit__(None, None, None) # pyright: ignore[reportUnknownMemberType]
356+
self._client = None

0 commit comments

Comments
 (0)