From 7855758c7f17c32cad3c73f5a5677fb87146e32a Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 31 May 2023 15:19:13 +0100 Subject: scripts: Ensure only one indexing job may run at a time. * scripts/index-genenetwork (main): Ensure no other indexing job is running. --- scripts/index-genenetwork | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork index 4da82e4..f7d4415 100755 --- a/scripts/index-genenetwork +++ b/scripts/index-genenetwork @@ -20,6 +20,7 @@ import os import pathlib import resource import shutil +import sys import tempfile from typing import Callable, Generator, Iterable, List @@ -359,7 +360,15 @@ def xapian_compact(combined_index: pathlib.Path, indices: List[pathlib.Path]) -> def main(xapian_directory: str, sql_uri: str) -> None: logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"), format='%(relativeCreated)s: %(levelname)s: %(message)s') - pathlib.Path(xapian_directory).mkdir(exist_ok=True) + + # Ensure no other build process is running. + if pathlib.Path(xapian_directory).exists(): + logging.error("Build directory %s already exists; " + "perhaps another build process is running.", + xapian_directory) + sys.exit(1) + + pathlib.Path(xapian_directory).mkdir() with temporary_directory("combined", xapian_directory) as combined_index: with temporary_directory("build", xapian_directory) as xapian_build_directory: logging.info("Indexing genes") -- cgit v1.2.3