code: def get_queue_func(request):
      
      def cleanup(request):
          conn.close()
  
      def queue_func(**kwargs):
          return conn.channel().basic_publish(
              exchange='', body=json.dumps(kwargs), routing_key=queue,
              properties=pika.BasicProperties(delivery_mode=2))
      server = request.registry.settings['queue_server']
      queue = request.registry.settings['queue_verification']
      conn = pika.BlockingConnection(pika.ConnectionParameters(host=server))
      request.add_finished_callback(cleanup)
      return queue_func
docs: Establish the connection to rabbitmq.