Closed jnsougata closed 2 years ago
hi @jnsougata could you explain (with use case code) how this behavior is better?
hi @jnsougata could you explain (with use case code) how this behavior is better?
Let's say I am making a discord bot using aiohttp. So I will already be having an aiohttp client session
. If I want to integrate async base there, then I will like to use that client session rather than internally created client session. In this case if we let async base create another session internally that will increase the number of sessions which is no good.
For example:
The connect method
actually assigns the session
to be used for API calls. This is how I made my lib. I want it into this lib for more flexibility...
async def setup_hook(self) -> None:
deta = Deta(os.getenv('DETA_TOKEN'))
await deta.connect(session=self.http._HTTPClient__session, loop=self.loop)
self.db = deta.base('01PIXEL')
self.drive = deta.drive('PixeL_@11223344')
@jnsougata, thank you for the additional useful input! seems like we need to rethink the async-base spec. we will start working on it soon and use your PR as a reference.
i'm merging this into the next
branch which will be the base for the major async release. thanks!
Previously it was just creating the client session internally. There's no option to use external session. Now as session is an optioal arg user may pass in an external session otherwise it will create it's own session automatically.