Skip to content

Commit 46375fc

Browse files
authored
Update README high-level consumer example
Update the example to show that upon exit, the consumer must call `close()`
1 parent 50efa73 commit 46375fc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ from confluent_kafka import Consumer
3535
c = Consumer({'bootstrap.servers': 'mybroker', 'group.id': 'mygroup',
3636
'default.topic.config': {'auto.offset.reset': 'smallest'}})
3737
c.subscribe(['mytopic'])
38-
while True:
38+
running = True
39+
while running:
3940
msg = c.poll()
4041
if not msg.error():
4142
print('Received message: %s' % msg.value().decode('utf-8'))
43+
else:
44+
running = False
4245
c.close()
4346
```
4447

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy