| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -599,6 +599,7 @@ def _to_client_batch_get_payload(online_config, table_name, batch): | |||
| 599 | 599 | ||
| 600 | 600 | _aioboto_session = None | |
| 601 | 601 | _aioboto_client = None | |
| 602 | + _aioboto_context_stack = None | ||
| 602 | 603 | ||
| 603 | 604 | ||
| 604 | 605 | def _get_aioboto_session(): | |
@@ -618,7 +619,7 @@ async def _get_aiodynamodb_client( | |||
| 618 | 619 | total_max_retry_attempts: Union[int, None], | |
| 619 | 620 | retry_mode: Union[Literal["legacy", "standard", "adaptive"], None], | |
| 620 | 621 | ): | |
| 621 | - global _aioboto_client | ||
| 622 | + global _aioboto_client, _aioboto_context_stack | ||
| 622 | 623 | if _aioboto_client is None: | |
| 623 | 624 | logger.debug("initializing the aiobotocore dynamodb client") | |
| 624 | 625 | ||
@@ -639,15 +640,23 @@ async def _get_aiodynamodb_client( | |||
| 639 | 640 | connector_args={"keepalive_timeout": keepalive_timeout}, | |
| 640 | 641 | ), | |
| 641 | 642 | ) | |
| 642 | - context_stack = contextlib.AsyncExitStack() | ||
| 643 | - _aioboto_client = await context_stack.enter_async_context(client_context) | ||
| 643 | + _aioboto_context_stack = contextlib.AsyncExitStack() | ||
| 644 | + _aioboto_client = await _aioboto_context_stack.enter_async_context( | ||
| 645 | + client_context | ||
| 646 | + ) | ||
| 644 | 647 | return _aioboto_client | |
| 645 | 648 | ||
| 646 | 649 | ||
| 647 | 650 | async def _aiodynamodb_close(): | |
| 648 | - global _aioboto_client | ||
| 651 | + global _aioboto_client, _aioboto_session, _aioboto_context_stack | ||
| 649 | 652 | if _aioboto_client: | |
| 650 | 653 | await _aioboto_client.close() | |
| 654 | + _aioboto_client = None | ||
| 655 | + if _aioboto_context_stack: | ||
| 656 | + await _aioboto_context_stack.aclose() | ||
| 657 | + _aioboto_context_stack = None | ||
| 658 | + if _aioboto_session: | ||
| 659 | + _aioboto_session = None | ||
| 651 | 660 | ||
| 652 | 661 | ||
| 653 | 662 | def _initialize_dynamodb_client( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments