-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving the boto3 resource with aioboto3 8.x #197
Comments
😄 I was waiting for an issue like this to appear. Yeah it can be done, https://docs.python.org/3/library/contextlib.html#contextlib.AsyncExitStack should be used as well, I'll look into making an aiohttp example this evening |
Thanks @terrycain, much appreciated. |
Thanks a lot @terrycain, good addition to the documentation. |
Can we please get a simpler approach for avoiding the use context manager at all? I believe long running application is a major use case as aiohttp is used for web servers. |
Not really, because we're pretty much wrapping boto3 and aiobotocore, it is what it is. If you dont care about closing resources, you can just |
I have a web app running inside an EC2 with an IAM Role attached to it and after some time running with the same client initialized with @terrycain do you have any ideia if this error is related to not using the
I'm using |
Its possible this is fixed in aioboto3 9.5.0, but there shouldn't be an issue reusing the same client. Realistically the part that fetches the metadata token should retry. If 9.5.0 doesn't work, see if you can replicate the issue just using the latest aiobotocore (also reusing the same client), as thats the library that handles all of the credentials logic. |
After the upgrade of aiobotocore to v 1.x.x, the documentation suggests that the aioboto3 resource should be used with an async context manager. This raises a small concern on my side about saving the resource.
My use case is one in which I run a web server with aiohttp, and need to access dynamodb for every request made. Previously I was able to initiate the resource and subsequently the
Table
-object in my database abstraction object, which was then stored in the aiohttp request context at application startup. I would then calltable.close()
at application shutdown and cleanup. Creating a new resource and table object for each request is too slow.It would be beneficial to add some documentation on how real world use cases are supported. Is there a way to maintain the
Table
-object with the new changes?The text was updated successfully, but these errors were encountered: