Skip to content

Commit 7121757

Browse files
hrchuedenhill
authored andcommitted
Refactoring example (#367, @hrchu)
* Refactoring example * Fix flake8 complain
1 parent 24aefad commit 7121757

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/consumer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def print_assignment(consumer, partitions):
100100
# End of partition event
101101
sys.stderr.write('%% %s [%d] reached end at offset %d\n' %
102102
(msg.topic(), msg.partition(), msg.offset()))
103-
elif msg.error():
103+
else:
104104
# Error
105105
raise KafkaException(msg.error())
106106
else:
@@ -113,5 +113,6 @@ def print_assignment(consumer, partitions):
113113
except KeyboardInterrupt:
114114
sys.stderr.write('%% Aborted by user\n')
115115

116-
# Close down consumer to commit final offsets.
117-
c.close()
116+
finally:
117+
# Close down consumer to commit final offsets.
118+
c.close()

0 commit comments

Comments
 (0)