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

jqueue: Don't return negative number for unchecked jobs when archiving


When the queue was empty, the calculation for unchecked jobs while
archiving would return -1. ``last_touched`` is set to 0, the job ID list
(``all_job_ids``) is empty. Calculating ``len(all_job_ids) -
last_touched - 1`` resulted in -1.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 9fe72672
No related branches found
No related tags found
No related merge requests found
...@@ -1321,7 +1321,7 @@ class JobQueue(object): ...@@ -1321,7 +1321,7 @@ class JobQueue(object):
all_job_ids = self._GetJobIDsUnlocked(archived=False) all_job_ids = self._GetJobIDsUnlocked(archived=False)
pending = [] pending = []
for idx, job_id in enumerate(all_job_ids): for idx, job_id in enumerate(all_job_ids):
last_touched = idx last_touched = idx + 1
# Not optimal because jobs could be pending # Not optimal because jobs could be pending
# TODO: Measure average duration for job archival and take number of # TODO: Measure average duration for job archival and take number of
...@@ -1351,7 +1351,7 @@ class JobQueue(object): ...@@ -1351,7 +1351,7 @@ class JobQueue(object):
if pending: if pending:
archived_count += self._ArchiveJobsUnlocked(pending) archived_count += self._ArchiveJobsUnlocked(pending)
return (archived_count, len(all_job_ids) - last_touched - 1) return (archived_count, len(all_job_ids) - last_touched)
@staticmethod @staticmethod
def _GetJobInfoUnlocked(job, fields): def _GetJobInfoUnlocked(job, fields):
......
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