pika – how to stop and start again rabbitmq consume in python

def consume():
      for method,props,body in channel.consume("q1_test"):
          print(body)
          consolidated.append(body)
          channel.basic_ack(mf.delivery_tag)
          if len(consolidated) == 10:
              channel.cancel()
              process_data(consolidated)

def process_data(data):
    # processes data

my consumer can process only few messages i just wanted to know how can i stop consuming after a few messages and start again and repeat the process. basic_cancel isnt helping.
using pika version 1.3.1, and erlang 22.2.7. and blocking connection.

Read more here: Source link