extras-buildsys/server Builder.py,1.35,1.36

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Fri May 5 02:10:42 UTC 2006


Author: dcbw

Update of /cvs/fedora/extras-buildsys/server
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18128/server

Modified Files:
	Builder.py 
Log Message:
Clean up a few more bugs


Index: Builder.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/Builder.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Builder.py	3 May 2006 04:04:28 -0000	1.35
+++ Builder.py	5 May 2006 02:10:39 -0000	1.36
@@ -59,6 +59,8 @@
         self._weight = weight
         self._type = btype
         self._seq_gen = Commands.SequenceGenerator()
+        self._lock = threading.Lock()
+        self._cmd_queue = []
 
         try:
             type, rest = urllib.splittype(address)
@@ -185,7 +187,6 @@
         building_jobs = cmd.jobs()
         reported_uniqids = []
         new_cmds = []
-        print "Building Jobs: %s" % building_jobs
         for item in building_jobs:
             (uniqid, status) = cmd.get_job(item)
             try:
@@ -213,9 +214,44 @@
                     self._prepping_jobs = True
 
         del reported_uniqids
-        print "New Commands: %s" % new_cmds
         return new_cmds
 
+    def _find_and_remove_cmd_for_ack(self, ack, old_cmd_type):
+        """Find a command in the sent command queue by sequence number
+        and command type.  Remove the command from the command queue
+        and return it."""
+
+        old_cmd = None
+        self._lock.acquire()
+        for queued_cmd in self._cmd_queue:
+            if queued_cmd.seq() == ack.acked_seq() and isinstance(queued_cmd, old_cmd_type):
+                old_cmd = queued_cmd
+                self._cmd_queue.remove(queued_cmd)
+                break
+        self._lock.release()
+        return old_cmd
+
+    def _handle_new_job_ack(self, ack):
+        """Handle a NewJobAck command by notifying the parent job
+        that this archjob is now in progress."""
+
+        old_cmd = self._find_and_remove_cmd_for_ack(ack, Commands.PlgCommandNewJobReq)
+        if old_cmd:
+            parent = old_cmd.parent_job()
+            archjob_id = ack.archjob_id()
+            archjob = ArchJob.ArchJob(self, parent, archjob_id, old_cmd.target_dict())
+            self._jobs[archjob_id] = archjob
+            parent.add_arch_job(archjob)
+
+    def _handle_job_status_ack(self, ack):
+        old_cmd = self._find_and_remove_cmd_for_ack(ack, Commands.PlgCommandJobStatus)
+        if old_cmd:
+            archjob_id = ack.archjob_id()
+            status = ack.status()
+            job = self._jobs[archjob_id]
+            job.set_builder_job_status(status)
+
+
 # HACK: This class is a hack to work around SSL hanging issues,
 # which cause the whole server to grind to a halt
 class BuildingJobsCheck(threading.Thread):
@@ -479,8 +515,6 @@
     def __init__(self, manager, cfg, address, weight, btype):
         Builder.__init__(self, manager, cfg, address, weight, btype)
         self._last_contact = 0
-        self._lock = threading.Lock()
-        self._cmd_queue = []
 
     def _init_builder(self, target_list):
         self._target_list = target_list
@@ -497,27 +531,6 @@
     def request_job_files(self, archjob):
         pass
 
-    def _handle_new_job_ack(self, ack):
-        """Handle a NewJobAck command by finding the original command
-        sent to the builder, removing it from the command queue, and notifying
-        the parent job that this archjob is now in progress."""
-
-        old_cmd = None
-        self._lock.acquire()
-        for queued_cmd in self._cmd_queue:
-            if queued_cmd.seq() == ack.acked_seq() and isinstance(queued_cmd, Commands.PlgCommandNewJobReq):
-                old_cmd = queued_cmd
-                self._cmd_queue.remove(queued_cmd)
-                break
-        self._lock.release()
-
-        if old_cmd:
-            parent = old_cmd.parent_job()
-            archjob_id = ack.archjob_id()
-            archjob = ArchJob.ArchJob(self, parent, archjob_id, old_cmd.target_dict())
-            self._jobs[archjob_id] = archjob
-            parent.add_arch_job(archjob)
-
     def _dispatch_command(self, cmd):
         name = cmd.name()
         if isinstance(cmd, Commands.PlgCommandSlots):
@@ -538,6 +551,8 @@
                 self._lock.acquire()
                 self._cmd_queue = self._cmd_queue + status_reqs
                 self._lock.release()
+        elif isinstance(cmd, Commands.PlgCommandJobStatusAck):
+            self._handle_job_status_ack(cmd)
         else:
             print "Builder Error (%s): unhandled command '%s'" % (self._address, cmd.name())
 




More information about the fedora-extras-commits mailing list