Skip to content

Commit

Permalink
find_media_errors.py: use cache only when already running
Browse files Browse the repository at this point in the history
  • Loading branch information
double16 committed Aug 15, 2024
1 parent 61ef3ce commit 6317144
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dvrprocess/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def split_every(n, iterable):
return [iterable[i:i + n] for i in range(0, len(iterable), n)]


def check_already_running():
def check_already_running(quiet=False):
"""
Check if other processes like me are running.
:return: True if there are other processes, False if I'm the only one.
Expand All @@ -926,7 +926,8 @@ def check_already_running():
except (PermissionError, AccessDenied, ProcessLookupError, NoSuchProcess):
pass
if len(others) > 0:
logger.error(f"process(es) already running: {list(map(lambda p: p.pid, others))}")
if not quiet:
logger.error(f"process(es) already running: {list(map(lambda p: p.pid, others))}")
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions dvrprocess/find_media_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def find_media_errors_cli(argv):
media_paths = common.get_media_paths(roots)
logger.debug("media_paths = %s", media_paths)

if common.check_already_running():
return 0
if common.check_already_running(quiet=True):
cache_only = True

generator = media_errors_generator(media_paths=media_paths, media_roots=roots,
time_limit=time_limit, check_compute=check_compute, cache_only=cache_only)
Expand Down

0 comments on commit 6317144

Please sign in to comment.