Use a try-except so that the pickle file is written even when we die

because of an unexpected exception.
This commit is contained in:
Guido van Rossum 1998-04-27 19:35:15 +00:00
parent e86271af72
commit bee64533d6

View file

@ -183,6 +183,8 @@ def main():
for arg in args: for arg in args:
c.addroot(arg) c.addroot(arg)
try:
if not norun: if not norun:
try: try:
c.run() c.run()
@ -196,11 +198,13 @@ def main():
if verbose > 0: if verbose > 0:
print "[report interrupted]" print "[report interrupted]"
finally:
if c.save_pickle(dumpfile): if c.save_pickle(dumpfile):
if dumpfile == DUMPFILE: if dumpfile == DUMPFILE:
print "Use ``%s -R'' to restart." % sys.argv[0] print "Use ``%s -R'' to restart." % sys.argv[0]
else: else:
print "Use ``%s -R -d %s'' to restart." % (sys.argv[0], dumpfile) print "Use ``%s -R -d %s'' to restart." % (sys.argv[0],
dumpfile)
def load_pickle(dumpfile=DUMPFILE, verbose=VERBOSE): def load_pickle(dumpfile=DUMPFILE, verbose=VERBOSE):