From 543b0b2194a37b7866b4a84bbce189fa61f30f79 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Wed, 25 Oct 2006 07:43:49 +0000
Subject: [PATCH] Randomize new jobs.

* distribute-tasks (read_new_tasks): Randomize the new tasks before
  inserting them first.
---
 ChangeLog        | 7 +++++++
 distribute-tasks | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 665f226..8a0ad4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-10-25  Per Cederqvist  <ceder@sedesopim.lysator.liu.se>
+	
+	Randomize new jobs.
+
+	* distribute-tasks (read_new_tasks): Randomize the new tasks
+	before inserting them first.
+
 2006-10-24  Per Cederqvist  <ceder@sedesopim.lysator.liu.se>
 
 	Prefer new jobs to old jobs.
diff --git a/distribute-tasks b/distribute-tasks
index e3aeacc..1e419a9 100755
--- a/distribute-tasks
+++ b/distribute-tasks
@@ -82,14 +82,18 @@ def read_tasks(lysrdiffpart):
 
 def read_new_tasks():
     new_found = False
+    new_tasks = []
     for line in file("/nobackup/backup.lysator/var/tasks"):
         info = parse_line(line)
         if (info.host(), info.directory()) not in tasks_per_source:
             info.set_lysrdiffpart(newtasks())
             tasks_per_source[(info.host(), info.directory())] = info
-	    ordered_tasks.insert(0, info)
+	    new_tasks.append(info)
             new_found = True
 
+    random.shuffle(new_tasks)
+
+    ordered_tasks = new_tasks + ordered_tasks
     return new_found
 
 def write_task_lists():
-- 
GitLab