tvalentyn commented on issue #22969:
URL: https://github.com/apache/beam/issues/22969#issuecomment-1462730124

   Taking a closer look, the unexpected behavior is not caused by Beam but 
rather how Python interprets a function with `yield` and `return` statements 
mixed together. See: 
https://stackoverflow.com/questions/16780002/return-in-generator-together-with-yield
 which summarizes it.
   
   For example:
   
   ```
   def foo(c):
     if (c):
       yield "foo"
     else:
       return "bar
   ```
   
   ```
   list(foo(True))
   Out: ['foo']
   ```
   
   ```
   list(foo(False))
   Out: []
   ```
   
   ```next(foo(False))``` raises StopIteration: bar
   
   Seems that such mix-and-match was an error in Python 2.


-- 
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