bryanyang0528/ksql-python

Bug: PEP 479 StopIteration leads to RuntimeError

HHArrowood opened this issue · 1 comments

In Python 3.7 and above, StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. This means that the next()

header = next(results)
will break things if it reaches the end of the results generator. See the discussion here: https://stackoverflow.com/questions/51700960/runtimeerror-generator-raised-stopiteration-every-time-i-try-to-run-app.

To fix this, simply replace the line mentioned above with

    try:
        header = next(results)
    except StopIteration:
        return
        ```

Hi @HHArrowood ,

Thank you for pointing out this issue. Would you mind submitting a new PR for fixing this?