From 1ce685312d3a2a0b25f677a8a6ff3dc99e8c2485 Mon Sep 17 00:00:00 2001 From: Grigoriev Semyon <33061489+grigoriev-semyon@users.noreply.github.com> Date: Wed, 6 Dec 2023 00:15:37 +0300 Subject: [PATCH] New example of `get_object` (#1062) * get_object example Co-authored-by: Alexander Mohr --------- Co-authored-by: Semyon Grigoriev Co-authored-by: Alexander Mohr --- examples/simple.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/simple.py b/examples/simple.py index 3d41c891..b3a30752 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -28,6 +28,15 @@ async def go(): resp = await client.get_object_acl(Bucket=bucket, Key=key) print(resp) + resp = await client.get_object(Bucket=bucket, Key=key) + async with resp['Body'] as stream: + await stream.read() # if you do not read the stream the connection cannot be re-used and will be dropped + print(resp) + """ + This is to ensure the connection is returned to the pool as soon as possible. + Otherwise the connection will be released after it is GC'd + """ + # delete object from s3 resp = await client.delete_object(Bucket=bucket, Key=key) print(resp)