예제 #1
0
    def __init__(self, url=None):
        """Create a new instance of the Connection object"""
        super(Connection, self).__init__()

        # Create a name for the connection
        self._name = '0x%x' % id(self)

        # Extract parts of connection URL for use later
        self._args = self._process_url(url or self.DEFAULT_URL)

        # General events and queues shared across threads
        self._events = events.Events()

        # A queue for the child threads to put exceptions in
        self._exceptions = queue.Queue()

        # One queue for writing frames, regardless of the channel sending them
        self._write_queue = queue.Queue()

        # Attributes for core object threads
        self._channel0 = None
        self._channels = dict()
        self._io = None

        # Used by Message for breaking up body frames
        self._maximum_frame_size = None

        # Connect to RabbitMQ
        self._connect()
예제 #2
0
 def setUp(self):
     self.connection = mock.MagicMock('rabbitpy.connection.Connection')
     self.connection._io = mock.Mock()
     self.connection._io.write_trigger = mock.Mock('socket.socket')
     self.connection._io.write_trigger.send = mock.Mock()
     self.connection._channel0 = mock.Mock()
     self.connection._channel0.properties = {}
     self.connection._events = events.Events()
     self.connection._exceptions = connection.queue.Queue()
     self.connection.open = True
     self.connection.closed = False
     self.channel = channel.Channel(1, {},
                                    self.connection._events,
                                    self.connection._exceptions,
                                    connection.queue.Queue(),
                                    connection.queue.Queue(),
                                    32768,
                                    self.connection._io.write_trigger,
                                    connection=self.connection)
     self.channel._set_state(self.channel.OPEN)
예제 #3
0
 def setUp(self):
     self._events = events.Events()