Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sdk/python/feast/infra/online_stores/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ def _to_client_batch_get_payload(online_config, table_name, batch):

_aioboto_session = None
_aioboto_client = None
_aioboto_context_stack = None


def _get_aioboto_session():
Expand All @@ -618,7 +619,7 @@ async def _get_aiodynamodb_client(
total_max_retry_attempts: Union[int, None],
retry_mode: Union[Literal["legacy", "standard", "adaptive"], None],
):
global _aioboto_client
global _aioboto_client, _aioboto_context_stack
if _aioboto_client is None:
logger.debug("initializing the aiobotocore dynamodb client")

Expand All @@ -639,15 +640,23 @@ async def _get_aiodynamodb_client(
connector_args={"keepalive_timeout": keepalive_timeout},
),
)
context_stack = contextlib.AsyncExitStack()
_aioboto_client = await context_stack.enter_async_context(client_context)
_aioboto_context_stack = contextlib.AsyncExitStack()
_aioboto_client = await _aioboto_context_stack.enter_async_context(
client_context
)
return _aioboto_client


async def _aiodynamodb_close():
global _aioboto_client
global _aioboto_client, _aioboto_session, _aioboto_context_stack
if _aioboto_client:
await _aioboto_client.close()
_aioboto_client = None
if _aioboto_context_stack:
await _aioboto_context_stack.aclose()
_aioboto_context_stack = None
if _aioboto_session:
_aioboto_session = None


def _initialize_dynamodb_client(
Expand Down
Loading