Skip to content

Commit

Permalink
Fix code sample typos for Context Manager Examples in README.rst file (
Browse files Browse the repository at this point in the history
  • Loading branch information
Jastor11 committed Mar 17, 2021
1 parent 40427e6 commit 332ac8a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ Context Manager Examples
.. code:: python
from contextlib import AsyncExitStack
from typing import
import aiobotocore.session
from aiobotocore.session import AioSession
# How to use in existing context manager
Expand All @@ -102,21 +101,21 @@ Context Manager Examples
self._s3_client = None
async def __aenter__(self):
session = aiobotocore.session.AioSession()
session = AioSession()
self._s3_client = await self._exit_stack.enter_async_context(session.create_client('s3'))
async def __aexit__(self, exc_type, exc_val, exc_tb):
await self._exit_stack.__aexit__(exc_type, exc_val, exc_tb)
# How to use with an external exit_stack
async def create_s3_client(session: aiobotocore.session.AioSession, exit_stack: AsyncExitStack):
async def create_s3_client(session: AioSession, exit_stack: AsyncExitStack):
# Create client and add cleanup
client = await exit_stack.enter_async_context(session.create_client('s3'))
return client
async def non_manager_example():
session = aiobotocore.session.AioSession()
session = AioSession()
async with AsyncExitStack() as exit_stack:
s3_client = await create_s3_client(session, exit_stack)
Expand Down

0 comments on commit 332ac8a

Please sign in to comment.