Skip to content

Commit c8d6cda

Browse files
committed
cli fixups: producer stdin/eof support; consumer unused e var
1 parent 46319a3 commit c8d6cda

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

kafka/cli/consumer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def run_cli(args=None):
8282
except KafkaError as e:
8383
logger.error(e)
8484
return 1
85-
except Exception as e:
85+
except Exception:
8686
logger.exception('Error!')
8787
return 1
8888
finally:

kafka/cli/producer/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import argparse
44
import logging
5+
import sys
56

67
from kafka import KafkaProducer
78

@@ -73,7 +74,12 @@ def log_result(res_or_err):
7374

7475
try:
7576
while True:
76-
value = input_py23()
77+
try:
78+
value = input_py23()
79+
except EOFError:
80+
value = sys.stdin.read().rstrip('\n')
81+
if not value:
82+
return 0
7783
producer.send(config.topic, value=value.encode(config.encoding)).add_both(log_result)
7884
except KeyboardInterrupt:
7985
logger.info('Bye!')

0 commit comments

Comments
 (0)