title: Kafka python consumers running in parallel threads
body: <p>I'm a total newbie in python and kafka. I have a script that should start three kafka consumers, wait for messages from those consumers and do some other things. At this point I don't even know if I'm going in the right direction so any help will be appreciated. </p>
  
  <pre><code>class MainClass():
      def do_something_before(self):
          # something is done here
  
      def start_consumer(self):
          consumer1_thread = threading.Thread(target=self.cons1, args=())
          consumer2_thread = threading.Thread(target=self.cons2, args=())
          consumer1_thread.daemon = True
          consumer2_thread.daemon = True
          consumer1_thread.start()
          consumer2_thread.start()
  
      def cons1(self):
          consumer = KafkaConsumer(bootstrap_servers='localhost:9092',
                                   auto_offset_reset='earliest')
          consumer.subscribe(['my-topic'])
          for message in consumer:
              print(message.value)
  
      def cons2(self):
          consumer = KafkaConsumer(bootstrap_servers='localhost:9092',
                                   auto_offset_reset='earliest')
          consumer.subscribe(['my2-topic'])
          for message in consumer:
              print(message.value)
  
      def keep_working(self):
          # something is done here
  
  if __name__ == 'main':
      g = MainClass()
      g.do_something_before()
      g.keep_working()
  </code></pre>