Consider the following interface:
def handle_product() -> AsyncIterable[Product]:
pass
where I can do whatever I want while possibly returning other products to be handled.
Let’s say in my specific implementation, I know I don’t have any additional products to return. I basically want the asynchronous equivalent of the following:
def handle_product() -> Iterable[Thing]:
# send my product somewhere
return []
However, simply converting this function to asynchronous will not do it because it will just return an Awaitable and not an AsyncIterable.
Is there a “normal” way to achieve this without resorting to something ugly like:
async def handle_product():
# asynchronous logic
return
yield