title: How to do a simple Pika SelectConnection to send a message, in python?
body: <p>I am trying to convert my code to send rabbitmq messages via Pika instead. I am having a lot of trouble understanding how to send a simple message using an asynchronous connection (such as SelectConnection).</p>
  
  <p>In my old code, which I use the amqp library I simply declare a class like this:</p>
  
  <pre><code>import amqp as amqp
  
  class MQ():
  
      mqConn = None
      channel = None
  
      def __init__(self):
          self.connect()
  
      def connect(self):
          if self.mqConn is None:
              self.mqConn = amqp.Connection(host="localhost", userid="dev", password="dev", virtual_host="/", insist=False)
              self.channel = self.mqConn.channel()
  
          elif not self.mqConn.connected:
              self.mqConn = amqp.Connection(host="localhost", userid="dev", password="dev", virtual_host="/", insist=False)
              self.channel = self.mqConn.channel()
  
      def sendMQ(self, message):
          self.connect()
          lMessage = amqp.Message(message)
          self.channel.basic_publish(lMessage, exchange="DevMatrixE", routing_key="dev_matrix_q") 
  </code></pre>
  
  <p>And then elsewhere in my code I call sendMQ("this is my message"), and then the code continues. I do not need to listen for acknowledgements etc.</p>
  
  <p>Could someone please write a simple class utilizing pika and SelectConnection that would also work to just send a message using sendMQ("this is my message")? I've looked at the pika examples but I don't know how to get around the ioloop and KeyboardInterrupt. I guess I'm just not sure how to make my code continue to run without all these try/excepts... Also, not exactly sure how I can pass my message on through all the callbacks...</p>
  
  <p>Any help is appreciated!</p>
  
  <p>Thanks.</p>