Issue
I am getting an error message in which it says that I forgot to await a couroutine, which is not true, as highlighted in the code.
This is the function:
def _aio(self, f):
""" Make some function run asynchronously. """
async def aio_wrapper(**kwargs):
f_bound = functools.partial(f, **kwargs)
loop = asyncio.get_running_loop()
return await loop.run_in_executor(self._executor, f_bound)
return aio_wrapper
Here is me using the code:
for key in image_keys:
res = self._aio(self._client.get_object)(Bucket=self.bucket_name, Key=key)
print(type(res))
Solution
You don't await
the aio_wrapper
:
res = await self._aio(self._client.get_object)(Bucket=self.bucket_name, Key=key)
When running self._aio(self._client.get_object)
your wrapper executes and returns a coroutine function which you have to call and await
.
Answered By - Bharel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.