Commit bee64533 authored by Guido van Rossum's avatar Guido van Rossum

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

because of an unexpected exception.
parent e86271af
...@@ -183,24 +183,28 @@ def main(): ...@@ -183,24 +183,28 @@ def main():
for arg in args: for arg in args:
c.addroot(arg) c.addroot(arg)
if not norun: try:
if not norun:
try:
c.run()
except KeyboardInterrupt:
if verbose > 0:
print "[run interrupted]"
try: try:
c.run() c.report()
except KeyboardInterrupt: except KeyboardInterrupt:
if verbose > 0: if verbose > 0:
print "[run interrupted]" print "[report interrupted]"
try: finally:
c.report() if c.save_pickle(dumpfile):
except KeyboardInterrupt: if dumpfile == DUMPFILE:
if verbose > 0: print "Use ``%s -R'' to restart." % sys.argv[0]
print "[report interrupted]" else:
print "Use ``%s -R -d %s'' to restart." % (sys.argv[0],
if c.save_pickle(dumpfile): 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): def load_pickle(dumpfile=DUMPFILE, verbose=VERBOSE):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment