Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bee6453

Browse files
committed
Use a try-except so that the pickle file is written even when we die
because of an unexpected exception.
1 parent e86271a commit bee6453

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

Tools/webchecker/webchecker.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,28 @@ def main():
183183
for arg in args:
184184
c.addroot(arg)
185185

186-
if not norun:
186+
try:
187+
188+
if not norun:
189+
try:
190+
c.run()
191+
except KeyboardInterrupt:
192+
if verbose > 0:
193+
print "[run interrupted]"
194+
187195
try:
188-
c.run()
196+
c.report()
189197
except KeyboardInterrupt:
190198
if verbose > 0:
191-
print "[run interrupted]"
199+
print "[report interrupted]"
192200

193-
try:
194-
c.report()
195-
except KeyboardInterrupt:
196-
if verbose > 0:
197-
print "[report interrupted]"
198-
199-
if c.save_pickle(dumpfile):
200-
if dumpfile == DUMPFILE:
201-
print "Use ``%s -R'' to restart." % sys.argv[0]
202-
else:
203-
print "Use ``%s -R -d %s'' to restart." % (sys.argv[0], dumpfile)
201+
finally:
202+
if c.save_pickle(dumpfile):
203+
if dumpfile == DUMPFILE:
204+
print "Use ``%s -R'' to restart." % sys.argv[0]
205+
else:
206+
print "Use ``%s -R -d %s'' to restart." % (sys.argv[0],
207+
dumpfile)
204208

205209

206210
def load_pickle(dumpfile=DUMPFILE, verbose=VERBOSE):

0 commit comments

Comments
 (0)