Skip to content

How to use aiobotocore context manager with aiohttp on_startup on_shutdown #955

Answered by thehesiod
kuk asked this question in Q&A
Discussion options

You must be logged in to vote

can use AsyncExitStack to abstract things

from contextlib import AsyncExitStack

exit_stack = app['exit_stack'] = AsyncExitStack()
app['client'] = await exit_stack.enter_async_context(session.create_client('dynamodb'))

...
await app['exit_stack'].__aexit__(...)

really would be nice if aiohttp provided an exit stack we could chain to.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kuk
Comment options

@thehesiod
Comment options

@kuk
Comment options

Answer selected by kuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants