Запускаю подписчика Rabbit в thread. Как его можно остановить из основного процесса?
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
def main():
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_consume(queue='hello', on_message_callback=callback, auto_ack=True)
thread = threading.Thread(
target=channel.start_consuming,
)
thread.start()
while True:
msg = input('enter msg:')
if msg == 'stop':
# how stop consumer Rabbit
print('Thread is stopped')
main()