# Path: cloudify/amqp_client.py
# class AMQPClient(object):
#     EVENTS_EXCHANGE_NAME = 'cloudify-events'
#     SOCKET_TIMEOUT = 5
#     CONNECTION_ATTEMPTS = 3
#     LOGS_EXCHANGE_NAME = 'cloudify-logs'
#     def __init__(self,
#                  amqp_user,
#                  amqp_pass,
#                  amqp_host,
#                  amqp_vhost,
#                  ssl_enabled,
#                  ssl_cert_path):
#     def _connect(self):
#     def publish_message(self, message, message_type):
#     def close(self):
# def create_client(amqp_host=None,
#                   amqp_user=None,
#                   amqp_pass=None,
#                   amqp_vhost=None,
#                   ssl_enabled=None,
#                   ssl_cert_path=None):
# 
# Path: cloudify/exceptions.py
# class ClosedAMQPClientException(Exception):
#     """Raised when attempting to use a closed AMQP client"""
#     pass


from threading import Thread, RLock, Event
from Queue import Queue
from cloudify import amqp_client
from cloudify.exceptions import ClosedAMQPClientException
    def __exit__(self, exc, val, tb):
        self.unregister_caller()

    def publish_message(self, message, message_type):
        self._queue.put((message, message_type))

    def close(self):
        self.unregister_caller()
        self._client.close()

    def _make_client(self):
        return amqp_client.create_client(*self._client_args,
                                         **self._client_kwargs)

    def _connect(self):
        self._client = self._make_client()
        self.client_started.set()
        self._thread = Thread(target=self._handle_publish_message)
        self._thread.start()

    def _disconnect(self):
        self._queue.put(_STOP)

    def _handle_publish_message(self):
        while True:
            request = self._queue.get()
            if request is _STOP:
                break
            try:
                self._client.publish_message(*request)

# Path: cloudify/amqp_client.py
# class AMQPClient(object):
#     EVENTS_EXCHANGE_NAME = 'cloudify-events'
#     SOCKET_TIMEOUT = 5
#     CONNECTION_ATTEMPTS = 3
#     LOGS_EXCHANGE_NAME = 'cloudify-logs'
#     def __init__(self,
#                  amqp_user,
#                  amqp_pass,
#                  amqp_host,
#                  amqp_vhost,
#                  ssl_enabled,
#                  ssl_cert_path):
#     def _connect(self):
#     def publish_message(self, message, message_type):
#     def close(self):
# def create_client(amqp_host=None,
#                   amqp_user=None,
#                   amqp_pass=None,
#                   amqp_vhost=None,
#                   ssl_enabled=None,
#                   ssl_cert_path=None):
# 
# Path: cloudify/exceptions.py
# class ClosedAMQPClientException(Exception):
#     """Raised when attempting to use a closed AMQP client"""
#     pass


# Path: cloudify/amqp_client_utils.py
from threading import Thread, RLock, Event
from Queue import Queue
from cloudify import amqp_client
from cloudify.exceptions import ClosedAMQPClientException

    def __exit__(self, exc, val, tb):
        self.unregister_caller()

    def publish_message(self, message, message_type):
        self._queue.put((message, message_type))

    def close(self):
        self.unregister_caller()
        self._client.close()

    def _make_client(self):
        return amqp_client.create_client(*self._client_args,
                                         **self._client_kwargs)

    def _connect(self):
        self._client = self._make_client()
        self.client_started.set()
        self._thread = Thread(target=self._handle_publish_message)
        self._thread.start()

    def _disconnect(self):
        self._queue.put(_STOP)

    def _handle_publish_message(self):
        while True:
            request = self._queue.get()
            if request is _STOP:
                break
            try:
                self._client.publish_message(*request)

            except ClosedAMQPClientException: