dstandish commented on PR #31987:
URL: https://github.com/apache/airflow/pull/31987#issuecomment-1668363062

   Yup I had the some thought, why yield at all if we're just going to accept 
one event.  It's possible that we could support both.  Immediately after we 
call `run`, nothing happens at that point and we can inspect whether it's a 
generator or just coroutine and handle it appropriately.  Thus I think we could 
incrementally expand the interface (by putting it in user's hands, that they 
can use simple return) while maintaining backcompat by supporting yielding 
events as well.  Or deprecate.
   
   Example code:
   ```python
   async def not_gen():
       return "hi"
   async def is_gen():
       yield "yo"
       return
   
   async def main():
       f = not_gen()
       g = is_gen()
       assert isinstance(f, Coroutine)
       assert isinstance(g, AsyncGenerator)
       print("getting ready to run things")
       print(await f)
       async for thing in g:
           print(thing)
   
   asyncio.run(main())
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to