]> granicus.if.org Git - python/commitdiff
Use a try-except so that the pickle file is written even when we die
authorGuido van Rossum <guido@python.org>
Mon, 27 Apr 1998 19:35:15 +0000 (19:35 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 27 Apr 1998 19:35:15 +0000 (19:35 +0000)
because of an unexpected exception.

Tools/webchecker/webchecker.py

index 5459e9772b9a9901aa48c852b52c35f3e322e329..bf56cece355d3594a99eebc46da20597753f9a94 100755 (executable)
@@ -183,24 +183,28 @@ def main():
     for arg in args:
         c.addroot(arg)
 
-    if not norun:
+    try:
+
+        if not norun:
+            try:
+                c.run()
+            except KeyboardInterrupt:
+                if verbose > 0:
+                    print "[run interrupted]"
+
         try:
-            c.run()
+            c.report()
         except KeyboardInterrupt:
             if verbose > 0:
-                print "[run interrupted]"
+                print "[report interrupted]"
 
-    try:
-        c.report()
-    except KeyboardInterrupt:
-        if verbose > 0:
-            print "[report interrupted]"
-
-    if c.save_pickle(dumpfile):
-        if dumpfile == DUMPFILE:
-            print "Use ``%s -R'' to restart." % sys.argv[0]
-        else:
-            print "Use ``%s -R -d %s'' to restart." % (sys.argv[0], dumpfile)
+    finally:
+        if c.save_pickle(dumpfile):
+            if dumpfile == DUMPFILE:
+                print "Use ``%s -R'' to restart." % sys.argv[0]
+            else:
+                print "Use ``%s -R -d %s'' to restart." % (sys.argv[0],
+                                                           dumpfile)
 
 
 def load_pickle(dumpfile=DUMPFILE, verbose=VERBOSE):