bug 456361, jarmaker leaves stale lockfiles when interrupted, r=ted
authorAxel Hecht <l10n@mozilla.com>
Mon, 22 Sep 2008 16:23:55 +0200
changeset 19501 e9794a8b579d8c454d8bddd1610a1918d11f986b
parent 19500 dcb55e794dd5fcb26034a1c9817ec2a934b5890b
child 19502 57b34e9fdb3af29cbb95ada8d23f5c798d5bfb2d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs456361
milestone1.9.1b1pre
bug 456361, jarmaker leaves stale lockfiles when interrupted, r=ted
config/JarMaker.py
--- a/config/JarMaker.py
+++ b/config/JarMaker.py
@@ -263,43 +263,48 @@ class JarMaker(object):
         jf = ZipFile(jarfilepath, 'w', lock = True)
       outHelper = self.OutputHelper_jar(jf)
     else:
       outHelper = getattr(self, 'OutputHelper_' + self.outputFormat)(jarfile)
     register = {}
     # This loop exits on either
     # - the end of the jar.mn file
     # - an line in the jar.mn file that's not part of a jar section
-    while True:
-      try:
-        l = lines.next()
-      except StopIteration:
-        # we're done with this jar.mn, and this jar section
-        self.finalizeJar(jarfile, chromebasepath, register)
-        if jf is not None:
-          jf.close()
-        # reraise the StopIteration for makeJar
-        raise
-      if self.ignore.match(l):
-        continue
-      m = self.regline.match(l)
-      if  m:
-        rline = m.group(1)
-        register[rline] = 1
-        continue
-      m = self.entryline.match(l)
-      if not m:
-        # neither an entry line nor chrome reg, this jar section is done
-        self.finalizeJar(jarfile, chromebasepath, register)
-        if jf is not None:
-          jf.close()
-        lines.pushback(l)
-        return
-      self._processEntryLine(m, sourcedirs, topsourcedir, localedirs,
-                            outHelper, jf)
+    # - on an exception raised, close the jf in that case in a finally
+    try:
+      while True:
+        try:
+          l = lines.next()
+        except StopIteration:
+          # we're done with this jar.mn, and this jar section
+          self.finalizeJar(jarfile, chromebasepath, register)
+          if jf is not None:
+            jf.close()
+          # reraise the StopIteration for makeJar
+          raise
+        if self.ignore.match(l):
+          continue
+        m = self.regline.match(l)
+        if  m:
+          rline = m.group(1)
+          register[rline] = 1
+          continue
+        m = self.entryline.match(l)
+        if not m:
+          # neither an entry line nor chrome reg, this jar section is done
+          self.finalizeJar(jarfile, chromebasepath, register)
+          if jf is not None:
+            jf.close()
+          lines.pushback(l)
+          return
+        self._processEntryLine(m, sourcedirs, topsourcedir, localedirs,
+                              outHelper, jf)
+    finally:
+      if jf is not None:
+        jf.close()
     return
 
   def _processEntryLine(self, m, 
                         sourcedirs, topsourcedir, localedirs,
                         outHelper, jf):
       out = m.group('output')
       src = m.group('source') or os.path.basename(out)
       # pick the right sourcedir -- l10n, topsrc or src