def queue_iterator(queue, no_ack=False, timeout=None): channel = queue.channel with eventlet.Timeout(timeout, exception=WaiterTimeout()): for _, msg in itermessages(channel.connection, channel, queue, limit=None, no_ack=no_ack): yield msg
def poll_messages(self, correlation_id): channel = self.channel conn = channel.connection for body, msg in itermessages(conn, channel, self.queue, limit=None): if correlation_id == msg.properties.get('correlation_id'): self.provider.handle_message(body, msg) break
def test_when_raises_socket_timeout(self): conn = self.MockConnection() conn.should_raise_timeout = True channel = Mock() channel.connection.client = conn it = common.itermessages(conn, channel, "q", limit=1, Consumer=MockConsumer) with self.assertRaises(StopIteration): it.next()
def test_when_raises_IndexError(self, deque): deque_instance = deque.return_value = Mock() deque_instance.popleft.side_effect = IndexError() conn = self.MockConnection() channel = Mock() it = common.itermessages(conn, channel, "q", limit=1, Consumer=MockConsumer) with self.assertRaises(StopIteration): it.next()
def test_when_raises_IndexError(self, deque): deque_instance = deque.return_value = Mock() deque_instance.popleft.side_effect = IndexError() conn = self.MockConnection() channel = Mock() conn.Consumer = MockConsumer it = common.itermessages(conn, channel, 'q', limit=1) with pytest.raises(StopIteration): next(it)
def test_when_raises_socket_timeout(self): conn = self.MockConnection() conn.should_raise_timeout = True channel = Mock() channel.connection.client = conn conn.Consumer = MockConsumer it = common.itermessages(conn, channel, 'q', limit=1) with pytest.raises(StopIteration): next(it)
def test_when_raises_socket_timeout(self): conn = self.MockConnection() conn.should_raise_timeout = True channel = Mock() channel.connection.client = conn it = common.itermessages(conn, channel, 'q', limit=1, Consumer=MockConsumer) with self.assertRaises(StopIteration): it.next()
def test_default(self): conn = self.MockConnection() channel = Mock() channel.connection.client = conn it = common.itermessages(conn, channel, "q", limit=1, Consumer=MockConsumer) ret = it.next() self.assertTupleEqual(ret, ("body", "message")) with self.assertRaises(StopIteration): it.next()
def test_default(self): conn = self.MockConnection() channel = Mock() channel.connection.client = conn conn.Consumer = MockConsumer it = common.itermessages(conn, channel, 'q', limit=1) ret = next(it) assert ret == ('body', 'message') with pytest.raises(StopIteration): next(it)
def test_default(self): conn = self.MockConnection() channel = Mock() channel.connection.client = conn conn.Consumer = MockConsumer it = common.itermessages(conn, channel, 'q', limit=1) ret = next(it) self.assertTupleEqual(ret, ('body', 'message')) with self.assertRaises(StopIteration): next(it)
def test_default(self): conn = self.MockConnection() channel = Mock() channel.connection.client = conn it = common.itermessages(conn, channel, 'q', limit=1, Consumer=MockConsumer) ret = it.next() self.assertTupleEqual(ret, ('body', 'message')) with self.assertRaises(StopIteration): it.next()
def test_default(self): conn = self.MockConnection() channel = Mock() it = common.itermessages(conn, channel, "q", limit=1, Consumer=MockConsumer) ret = it.next() self.assertTupleEqual(ret, ("body", "message")) with self.assertRaises(StopIteration): it.next()