algolia / algoliasearch-client-python

⚡️ A fully-featured and blazing-fast Python API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/python/?language=python
MIT License
196 stars 67 forks source link

add await to helpers async when it is a coroutine #562

Open thiagosalvatore opened 9 months ago

thiagosalvatore commented 9 months ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Need Doc update no

Describe your change

Add checking for coroutine on async gen helper to await it instead of just returning.

before:

await (await self.client.search_async)

after:

await self.client.search_async

What problem is this fixing?

When using some async methods that simply returns the async transport (like search_async) we were having to manually call await twice (like below). It was happening because we were only awaiting things on the helper if they were a generator, but not if they were a coroutine.

thiagosalvatore commented 9 months ago

@shortcuts @millotp see what do you think about this change, please