def connect(self, debug=False):

        """This method connects to RabbitMQ, returning the connection handle.
        When the connection is established, the on_connection_open method
        will be invoked by pika. If you want the reconnection to work, make
        sure you set stop_ioloop_on_close to False, which is not the default
        behavior of this adapter.

        :rtype: pika.SelectConnection

        """

        results                 = build_dict("FAILED", "Not Connected", {})

        try:
    
            # Setup the Credentials
            self.lg("Setting up Credentials", 6)
            self.m_credentials  = pika.PlainCredentials(self.m_app_config["Account"]["User"], self.m_app_config["Account"]["Password"])

            # Setup the Connection Parameters
            self.lg("Setting up Connection Parameters", 6)
            self.m_conn_params  = pika.ConnectionParameters(
                                        host=self.m_host_list,
                                        credentials=self.m_credentials)

            # Setup the Connection
            self.lg("Setting up Connection", 6)
            self.m_connection   = pika.SelectConnection(pika.URLParameters(self.m_url),
                                        self.on_connection_open,
                                        stop_ioloop_on_close=False)

            self.lg("Done Building Connection", 6)

            # Setup the Channel
            results             = build_dict("SUCCESS", "Connected", {})

        except Exception,k:
            err_msg             = "Failed to establish connection with Ex(" + str(k) + ")"
            self.lg("ERROR: " + str(err_msg), 0)
            self.m_status       = "Not Connected"
            results             = build_dict("FAILED", str(err_msg), {})
        # end of try/ex

        return results
    # end of connect
dataset/ETHPy150Open GetLevvel/message-simulator/src/rabbit_message_publisher.py/RabbitMessagePublisher.connect/original