extras-buildsys/server ArchJob.py,1.16,1.16.2.1

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Tue Oct 25 14:31:40 UTC 2005


Author: dcbw

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

Modified Files:
      Tag: STABLE_0_4
	ArchJob.py 
Log Message:
Sync with HEAD - retry downloads from builders up to 3 times


Index: ArchJob.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/ArchJob.py,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- ArchJob.py	16 Sep 2005 18:11:20 -0000	1.16
+++ ArchJob.py	25 Oct 2005 14:31:38 -0000	1.16.2.1
@@ -168,22 +168,28 @@
                 self._set_status('downloading')
                 for f in self._dl_files():
                     uf = urllib.unquote(f)
-                    self.downloads[uf] = 0
+                    dl_dict = {}
+                    dl_dict['status'] = 'waiting'
+                    dl_dict['retries'] = 0
+                    dl_dict['wait_time'] = 0
+                    self.downloads[uf] = dl_dict
         elif self.status == 'downloading':
             # Start grabbing the next undownloaded file, but only
             # if we aren't already pulling one down
-            #
-            # Download states:
-            #   0: waiting
-            #   1: in progress
-            #   2: error
-            #   3: done
             undownloaded = False
             failed = False
             for url in self.downloads.keys():
-                dl_status = self.downloads[url]
-                if dl_status == 0:
-                    # spawn the download
+                dl_dict = self.downloads[url]
+                dl_status = dl_dict['status']
+                if dl_status == 'waiting':
+                    # If the download got retried due to a previous
+                    # download error, we may have to wait a bit
+                    if dl_dict['wait_time'] > 0:
+                        dl_dict['wait_time'] = dl_dict['wait_time'] - 1
+                        undownloaded = True
+                        continue
+
+                    # Otherwise, spawn the download thread to grab the file
                     target_dir = os.path.join(self.par_job.get_stage_dir(), self._target_dict['arch'])
                     if not os.path.exists(target_dir):
                         os.makedirs(target_dir)
@@ -196,22 +202,20 @@
                                         target_dir, ['.rpm', '.log'], None)
                         dl_thread.start()
                         undownloaded = True
-                        self.downloads[url] = 1 # In Progress
+                        dl_dict['status'] = 'in-progress'
                     except FileDownloader.FileNameException, e:
                         print "%s (%s/%s): [ %s ] Bad file name error when getting %s: '%s'" % (self.par_job.uid,
                                     self.par_job.package, self._target_dict['arch'], self.bci.address(), url, e)
-                        self.downloads[url] = 2 # Error
+                        # Hard error, we don't retry this one
+                        dl_dict['status'] = 'error'
                     break
-                elif dl_status == 1:
-                    # in progress
+                elif dl_status == 'in-progress':
                     undownloaded = True
                     break
-                elif dl_status == 2:
-                    # error
+                elif dl_status == 'error':
                     failed = True
                     continue
-                elif dl_status == 3:
-                    # this one is done
+                elif dl_status == 'done':
                     continue
 
             # All done downloading?
@@ -223,13 +227,28 @@
                 self._set_status('done')
                 self.par_job.wake()
 
+    def dl_callback(self, status, cb_data):
+        url = cb_data
+        dl_dict = self.downloads[url]
+        if status == 'done':
+            dl_dict['status'] = 'done'
+        elif status == 'failed':
+            # Retry the download up to 3 times, then fail it
+            if dl_dict['retries'] >= 3:
+                dl_dict['status'] = 'error'
+            else:
+                dl_dict['status'] = 'waiting'
+                dl_dict['wait_time'] = 5  # Wait a bit before trying again
+                dl_dict['retries'] = dl_dict['retries'] + 1
+
     def _print_downloaded_files(self):
         file_string = ""
         ndownloads = len(self.downloads.keys())
         for url in self.downloads.keys():
             filename = os.path.basename(url)
             string = "'" + filename + "'"
-            if self.downloads[url] == 2:
+            dl_dict = self.downloads[url]
+            if dl_dict['status'] == 'error':
                 string = string + " (failed)"
             file_string = file_string + string
             if url != self.downloads.keys()[ndownloads - 1]:
@@ -238,13 +257,6 @@
         print "%s (%s/%s): Build result files - [ %s ]" % (self.par_job.uid,
                     self.par_job.package, self._target_dict['arch'], file_string)
 
-    def dl_callback(self, status, cb_data):
-        url = cb_data
-        if status == 'done':
-            self.downloads[url] = 3
-        elif status == 'failed':
-            self.downloads[url] = 2
-
     def get_status(self):
         return self.status
 




More information about the fedora-extras-commits mailing list