From 5ff2dfcbb7a45a9181baaec15ce974004edfc50d Mon Sep 17 00:00:00 2001 From: Javeme Date: Thu, 14 Jan 2016 17:56:01 +0800 Subject: [PATCH] py3: Replaces xrange() with six.moves.range() Since xrange has been removed in Python 3, this patch let's replace xrange() with six.moves.range() to provide py3 compatibility. Change-Id: I85e0748786867334756a51dcb834f84ffd1e55a7 --- oslo_messaging/_drivers/pika_driver/pika_poller.py | 2 +- tools/simulator.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/oslo_messaging/_drivers/pika_driver/pika_poller.py b/oslo_messaging/_drivers/pika_driver/pika_poller.py index 3533dad2f..68edc1247 100644 --- a/oslo_messaging/_drivers/pika_driver/pika_poller.py +++ b/oslo_messaging/_drivers/pika_driver/pika_poller.py @@ -143,7 +143,7 @@ class PikaPoller(object): LOG.exception("Unexpected error during closing connection") self._connection = None - for i in xrange(len(self._message_queue) - 1, -1, -1): + for i in six.moves.range(len(self._message_queue) - 1, -1, -1): message = self._message_queue[i] if message.need_ack(): del self._message_queue[i] diff --git a/tools/simulator.py b/tools/simulator.py index 0bc0c3ba3..abe8e54d6 100755 --- a/tools/simulator.py +++ b/tools/simulator.py @@ -19,6 +19,7 @@ import datetime import logging import os import random +import six import string import sys import threading @@ -261,7 +262,7 @@ def send_msg(c_id, transport, target, wait_after_msg, timeout, is_cast, client.send_msg() else: LOG.debug("Sending %d messages using client %d", messages_count, c_id) - for _ in xrange(0, messages_count): + for _ in six.moves.range(0, messages_count): client.send_msg() LOG.debug("Client %d has sent %d messages", c_id, messages_count)