wglass / kiel

Kafka python client for asynchronous tornado applications.
Apache License 2.0
41 stars 14 forks source link

Produce fails on Python 3.7 #34

Open Glutexo opened 6 years ago

Glutexo commented 6 years ago

With Python 3.7, Producer.produce fails with

KeyError: 'popitem(): dictionary is empty'

in iterables.py:17, the drain function:

https://github.com/wglass/kiel/blob/12664fae522d95536c977bc3868951e7dce3daa0/kiel/iterables.py#L17

On Python 3.6 this works fine.

Here in this Gist there is a simple Tornado app that produces to Kafka messages read from input. Run with python somple_tornado_app.py produce. There is also a full error output of the failure.

Glutexo commented 6 years ago

Did some research and it looks like it‘s because behavior of generators changed in Python 3.7. Now, you should not raise StopIteration manually in the generator, but instead of that just return.