Browse code

Fixed code 1) to collect logs even though building rpm failed 2) added waiting for rest of threads to main thread incase of failure

Divya Thaluru authored on 2015/05/28 08:04:15
Showing 2 changed files
... ...
@@ -131,6 +131,7 @@ class PackageManager(object):
131 131
 
132 132
         return True
133 133
     
134
+    #just to be safe, we have this method
134 135
     def checkIfAnyThreadsAreHanged(self):
135 136
         currentTime = time.time()
136 137
         listThreadsHanged=[]
... ...
@@ -139,7 +140,7 @@ class PackageManager(object):
139 139
             if not self.mapOutputThread.has_key(t):
140 140
                 self.logger.debug("Calculating running time for thread "+t)
141 141
                 launchTime = self.mapThreadsLaunchTime[t]
142
-                if (currentTime - launchTime) > 3600.0:
142
+                if (currentTime - launchTime) > 7200.0:
143 143
                     listThreadsHanged.append(t)
144 144
             
145 145
         if len(listThreadsHanged) > 0:
... ...
@@ -154,8 +155,8 @@ class PackageManager(object):
154 154
             if self.checkIfAnyThreadsAreCompleted():
155 155
                 break
156 156
             self.checkIfAnyThreadsAreHanged()
157
-            self.logger.info("Sleeping for 30 seconds")
158
-            time.sleep(30)
157
+            self.logger.info("Sleeping for 10 seconds")
158
+            time.sleep(10)
159 159
     
160 160
     def buildToolChain(self):
161 161
         try:
... ...
@@ -211,14 +212,15 @@ class PackageManager(object):
211 211
             self.logger.error("Failed and exited gracefully")
212 212
             returnVal = False
213 213
         finally:
214
-            if len(self.listThreads) > 0:
215
-                self.killAllThreads()
214
+            self.waitForRemainingThreads()
216 215
         return returnVal
217 216
     
218
-    def killAllThreads(self):
219
-        self.logger.info("Killing all remaining threads")
217
+    def waitForRemainingThreads(self):
218
+        self.logger.info("Waiting for all remaining threads to complete")
219
+        for t in self.listThreads:
220
+            self.listThreads[t].join()
220 221
         return
221
-    
222
+
222 223
     def findNextPackageToBuild(self):
223 224
         listOfPackagesNextToBuild=[]
224 225
         self.logger.info("Checking for next possible packages to build")
... ...
@@ -105,9 +105,15 @@ class PackageUtils(object):
105 105
         self.copySourcesTobuildroot(listSourcesFiles,package,chrootSourcePath)
106 106
         self.copySourcesTobuildroot(listPatchFiles,package,chrootSourcePath)
107 107
         
108
-        listRPMFiles = self.buildRPM(chrootSpecPath+"/"+specName,chrootLogsFilePath, chrootCmd)
109
-        if destLogPath is not None:
110
-            shutil.copy2(chrootLogsFilePath, destLogPath)
108
+        listRPMFiles=[]
109
+        try:
110
+            listRPMFiles = self.buildRPM(chrootSpecPath+"/"+specName,chrootLogsFilePath, chrootCmd)
111
+        except Exception as e:
112
+            self.logger.error("Failed while building rpm:"+package)
113
+            raise e
114
+        finally:
115
+            if destLogPath is not None:
116
+                shutil.copy2(chrootLogsFilePath, destLogPath)
111 117
 
112 118
         for rpmFile in listRPMFiles:
113 119
             self.copyRPM(chrootID+"/"+rpmFile, constants.rpmPath)