Skip to content
Snippets Groups Projects
Commit 03b63608 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

jqueue: Rename current_op to better reflect what it actually is


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent fa4aa6b4
No related branches found
No related tags found
No related merge requests found
...@@ -176,7 +176,7 @@ class _QueuedJob(object): ...@@ -176,7 +176,7 @@ class _QueuedJob(object):
""" """
# pylint: disable-msg=W0212 # pylint: disable-msg=W0212
__slots__ = ["queue", "id", "ops", "log_serial", "current_op", __slots__ = ["queue", "id", "ops", "log_serial", "ops_iter",
"received_timestamp", "start_timestamp", "end_timestamp", "received_timestamp", "start_timestamp", "end_timestamp",
"__weakref__"] "__weakref__"]
...@@ -210,7 +210,7 @@ class _QueuedJob(object): ...@@ -210,7 +210,7 @@ class _QueuedJob(object):
"""Initializes in-memory variables. """Initializes in-memory variables.
""" """
obj.current_op = None obj.ops_iter = None
def __repr__(self): def __repr__(self):
status = ["%s.%s" % (self.__class__.__module__, self.__class__.__name__), status = ["%s.%s" % (self.__class__.__module__, self.__class__.__name__),
...@@ -766,13 +766,13 @@ class _JobProcessor(object): ...@@ -766,13 +766,13 @@ class _JobProcessor(object):
# lookups # lookups
# TODO: Consider splitting _QueuedJob.ops into two separate lists, one for # TODO: Consider splitting _QueuedJob.ops into two separate lists, one for
# pending and one for processed ops. # pending and one for processed ops.
if job.current_op is None: if job.ops_iter is None:
job.current_op = enumerate(job.ops) job.ops_iter = enumerate(job.ops)
# Find next opcode to run # Find next opcode to run
while True: while True:
try: try:
(idx, op) = job.current_op.next() (idx, op) = job.ops_iter.next()
except StopIteration: except StopIteration:
raise errors.ProgrammerError("Called for a finished job") raise errors.ProgrammerError("Called for a finished job")
......
...@@ -756,11 +756,11 @@ class TestJobProcessor(unittest.TestCase): ...@@ -756,11 +756,11 @@ class TestJobProcessor(unittest.TestCase):
[constants.OP_STATUS_QUEUED [constants.OP_STATUS_QUEUED
for _ in range(len(ops) - successcount)]]) for _ in range(len(ops) - successcount)]])
self.assert_(job.current_op) self.assert_(job.ops_iter)
# Serialize and restore (simulates program restart) # Serialize and restore (simulates program restart)
newjob = jqueue._QueuedJob.Restore(queue, job.Serialize()) newjob = jqueue._QueuedJob.Restore(queue, job.Serialize())
self.assertFalse(newjob.current_op) self.assertFalse(newjob.ops_iter)
self._TestPartial(newjob, successcount) self._TestPartial(newjob, successcount)
def _TestPartial(self, job, successcount): def _TestPartial(self, job, successcount):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment