title: Python - RabbitMQ Pika consumer - How to use async function as callback
body: <p>I have the following code where I initialize a consumer listening to a queue.</p>
  <pre><code>consumer = MyConsumer()
  consumer.declare_queue(queue_name=&quot;my-jobs&quot;)
  consumer.declare_exchange(exchange_name=&quot;my-jobs&quot;)
  consumer.bind_queue(
      exchange_name=&quot;my-jobs&quot;, queue_name=&quot;my-jobs&quot;, routing_key=&quot;jobs&quot;
  )
  consumer.consume_messages(queue=&quot;my-jobs&quot;, callback=consumer.consume)
  </code></pre>
  <p>The problem is that the consume method is defined as follows:</p>
  <pre><code>async def consume(self, channel, method, properties, body):
  </code></pre>
  <p>Inside the consume method, we need to await async functions, but this produces an error &quot;coroutine is not awaited&quot; for the consume function. Is there a way to use async function as a callback in pika?</p>