Skip to content

Instantly share code, notes, and snippets.

@andgineer
Created October 15, 2021 04:59
Show Gist options
  • Save andgineer/0908a17259fd89a9ef568d475821dece to your computer and use it in GitHub Desktop.
Save andgineer/0908a17259fd89a9ef568d475821dece to your computer and use it in GitHub Desktop.
async version of nullcontext
session = get_session() if s3 is None else None
async with session.create_client(
"s3"
) if s3 is None else contextlib.AsyncExitStack() as s3_temp:
s3_object = await (s3 or s3_temp).get_object(Bucket=bucket, Key=key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment