rocketmq-client-python
rocketmq-client-python copied to clipboard
readme example consumer.shutdown() is unreachable
BUG REPORT
consumer.shutdown() is unreachable :
import time
from rocketmq.client import PushConsumer, ConsumeStatus
def callback(msg):
print(msg.id, msg.body)
return ConsumeStatus.CONSUME_SUCCESS
consumer = PushConsumer('CID_XXX')
consumer.set_name_server_address('127.0.0.1:9876')
consumer.subscribe('YOUR-TOPIC', callback)
consumer.start()
while True:
time.sleep(3600)
consumer.shutdown() # <- This code is unreachable
maybe can be changed to
try:
while True:
time.sleep(3600)
except KeyboardInterrupt:
consumer.shutdown()