bryanyang0528 / ksql-python

A python wrapper for the KSQL REST API.
MIT License
159 stars 67 forks source link

Bug: PEP 479 StopIteration leads to RuntimeError #93

Closed HHArrowood closed 3 years ago

HHArrowood commented 3 years ago

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() https://github.com/bryanyang0528/ksql-python/blob/9d650a067a71c97fb169c521ba54985189f56a33/ksql/utils.py#L103 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
bryanyang0528 commented 3 years ago

Hi @HHArrowood ,

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