Browse Source

fsck: limit max retries so we don't get stuck in a loop forever

tags/nilmdb-1.9.2^0
Jim Paris 7 years ago
parent
commit
6868f5f126
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      nilmdb/fsck/fsck.py

+ 3
- 2
nilmdb/fsck/fsck.py View File

@@ -44,15 +44,16 @@ def err(format, *args):
fprintf(sys.stderr, format, *args)

# Decorator that retries a function if it returns a specific value
def retry_if_raised(exc, message = None):
def retry_if_raised(exc, message = None, max_retries = 100):
def f1(func):
def f2(*args, **kwargs):
while True:
for n in range(max_retries):
try:
return func(*args, **kwargs)
except exc as e:
if message:
log("%s\n\n", message)
raise Exception("Max number of retries (%d) exceeded; giving up")
return f2
return f1



Loading…
Cancel
Save