Commit f1501b3f authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Replace all xrange() with range()


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 008b92fa
......@@ -1527,7 +1527,7 @@ def GenerateTable(headers, fields, separator, data,
args = []
if line is None:
line = ['-' for _ in fields]
for idx in xrange(len(fields)):
for idx in range(len(fields)):
if separator is None:
args.append(mlens[idx])
args.append(line[idx])
......
......@@ -305,7 +305,7 @@ class WorkerPool(object):
elif current_count < num_workers:
# Create (num_workers - current_count) new workers
for _ in xrange(num_workers - current_count):
for _ in range(num_workers - current_count):
worker = self._worker_class(self, self._NewWorkerIdUnlocked())
self._workers.append(worker)
worker.start()
......
......@@ -159,7 +159,7 @@ def TestClusterBurnin():
try:
try:
num = qa_config.get('options', {}).get('burnin-instances', 1)
for _ in xrange(0, num):
for _ in range(0, num):
instances.append(qa_config.AcquireInstance())
except qa_error.OutOfInstancesError:
print "Not enough instances, continuing anyway."
......
......@@ -492,7 +492,7 @@ class TestSharedLock(_ThreadedTestCase):
self.sl.acquire()
# Start shared acquires with timeout between 0 and 20 ms
for i in xrange(11):
for i in range(11):
self._addThread(target=_AcquireWithTimeout,
args=(shared, i * 2.0 / 1000.0))
......@@ -503,7 +503,7 @@ class TestSharedLock(_ThreadedTestCase):
# Release lock
self.sl.release()
for _ in xrange(11):
for _ in range(11):
self.assertEqual(self.done.get_nowait(), "timeout")
self.assertRaises(Queue.Empty, self.done.get_nowait)
......@@ -583,10 +583,10 @@ class TestSharedLock(_ThreadedTestCase):
self.assertEqual(shrcnt3, 0)
self.assertEqual(shrcnt3, 0)
for _ in xrange(3):
for _ in range(3):
self.assertEqual(self.done.get_nowait(), "exclusive 1")
for _ in xrange(3):
for _ in range(3):
self.assertEqual(self.done.get_nowait(), "exclusive 2")
self.assertRaises(Queue.Empty, self.done.get_nowait)
......@@ -615,7 +615,7 @@ class TestSharedLock(_ThreadedTestCase):
self.sl.release()
acquires = []
for _ in xrange(3):
for _ in range(3):
ev = threading.Event()
self._addThread(target=_AcquireShared, args=(ev, ))
acquires.append(ev)
......@@ -675,7 +675,7 @@ class TestSharedLock(_ThreadedTestCase):
self.done.put("shared2")
self.sl.release()
for _ in xrange(10):
for _ in range(10):
self._addThread(target=_AcquireSharedSimple)
# Tell exclusive lock to release
......@@ -691,12 +691,12 @@ class TestSharedLock(_ThreadedTestCase):
self.assertEqual(self.sl._count_pending(), 0)
# Check sequence
for _ in xrange(3):
for _ in range(3):
self.assertEqual(self.done.get_nowait(), "shared")
self.assertEqual(self.done.get_nowait(), "exclusive")
for _ in xrange(10):
for _ in range(10):
self.assertEqual(self.done.get_nowait(), "shared2")
self.assertRaises(Queue.Empty, self.done.get_nowait)
......
......@@ -64,7 +64,7 @@ class TestWorkerpool(unittest.TestCase):
try:
self._CheckWorkerCount(wp, 3)
for i in xrange(10):
for i in range(10):
wp.AddTask("Hello world %s" % i)
wp.Quiesce()
......@@ -101,7 +101,7 @@ class TestWorkerpool(unittest.TestCase):
ctx = ChecksumContext()
checksum = ChecksumContext.CHECKSUM_START
for i in xrange(1, 100):
for i in range(1, 100):
checksum = ChecksumContext.UpdateChecksum(checksum, i)
wp.AddTask(ctx, i)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment