Exemplo n.º 1
0
    def channel(self, blocking_read=False):
        """Create a new channel

        If blocking_read is True, the cross-thread Queue.get use will use
        blocking operations that lower resource utilization and increase
        throughput. However, due to how Python's blocking Queue.get is
        implemented, KeyboardInterrupt is not raised when CTRL-C is
        pressed.

        :param bool blocking_read: Enable for higher throughput
        :raises: rabbitpy.exceptions.AMQPException
        :raises: rabbitpy.exceptions.RemoteClosedChannelException

        """
        with self._channel_lock:
            channel_id = self._get_next_channel_id()
            channel_frames = queue.Queue()
            self._channels[channel_id] = \
                channel.Channel(channel_id,
                                self.capabilities,
                                self._events,
                                self._exceptions,
                                channel_frames,
                                self._write_queue,
                                self._max_frame_size,
                                self._io.write_trigger,
                                blocking_read)
            self._add_channel_to_io(self._channels[channel_id], channel_frames)
            self._channels[channel_id].open()
            return self._channels[channel_id]
Exemplo n.º 2
0
 def setUp(self):
     self.chan = channel.Channel(1, {}, None, None, None, None, 32768, None)
     self.queue = amqp_queue.Queue(self.chan, self.NAME, self.DURABLE,
                                   self.EXCLUSIVE, self.AUTO_DELETE,
                                   self.MAX_LENGTH, self.MESSAGE_TTL,
                                   self.EXPIRES, self.DEAD_LETTER_EXCHANGE,
                                   self.DEAD_LETTER_ROUTING_KEY)
Exemplo n.º 3
0
 def test_basic_ack_invokes_write_frame(self):
     with mock.patch('rabbitpy.channel.Channel.write_frame') as method:
         chan = channel.Channel(1, {}, None, None, None, None, 32768, None)
         obj = amqp.AMQP(chan)
         obj.basic_ack(123, True)
         args, kwargs = method.call_args
         self.assertEqual(len(args), 1)
         self.assertEqual(args[0].delivery_tag, 123)
         self.assertEqual(args[0].multiple, True)
Exemplo n.º 4
0
 def channel(self):
     """Create a new channel"""
     channel_id = self._get_next_channel_id()
     channel_frames = queue.Queue()
     self._channels[channel_id] = channel.Channel(channel_id, self._events,
                                                  self._exceptions,
                                                  channel_frames,
                                                  self._write_queue,
                                                  self._maximum_frame_size,
                                                  self._io.write_trigger)
     self._add_channel_to_io(self._channels[channel_id], channel_frames)
     self._channels[channel_id].open()
     return self._channels[channel_id]
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def setUp(self):
     self.chan = channel.Channel(1, {}, None, None, None, None, 32768, None)
Exemplo n.º 7
0
 def setUp(self):
     self.chan = channel.Channel(1, {}, None, None, None, None, 32768, None)
     self.queue = amqp_queue.Queue(self.chan)