rocketmq-client-python icon indicating copy to clipboard operation
rocketmq-client-python copied to clipboard

readme example consumer.shutdown() is unreachable

Open shane965 opened this issue 3 years ago • 0 comments

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()

shane965 avatar May 11 '22 03:05 shane965