diff --git a/reframe/frontend/autodetect.py b/reframe/frontend/autodetect.py index 88d02ac45a..4a1d6d55b8 100644 --- a/reframe/frontend/autodetect.py +++ b/reframe/frontend/autodetect.py @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: BSD-3-Clause -import fcntl import json import jsonschema import os @@ -80,8 +79,7 @@ def _validate_info(info, schema): def _load_info(filename, schema=None): try: with open(filename) as fp: - with osext.lock_file(fp, fcntl.LOCK_SH): - return _validate_info(json.load(fp), schema) + return _validate_info(json.load(fp), schema) except OSError as e: getlogger().warning( f'could not load file: {filename!r}: {e}' @@ -100,8 +98,7 @@ def _save_info(filename, topo_info): os.makedirs(os.path.dirname(filename), exist_ok=True) try: with open(filename, 'w') as fp: - with osext.lock_file(fp, fcntl.LOCK_EX): - json.dump(topo_info, fp, indent=2) + json.dump(topo_info, fp, indent=2) except OSError as e: getlogger().warning( f'could not save topology file: {filename!r}: {e}' diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index 24ff73aa51..1ef9045bae 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -9,7 +9,6 @@ import collections.abc import errno -import fcntl import getpass import grp import os @@ -305,28 +304,6 @@ def rmtree(*args, max_retries=3, **kwargs): raise -# FIXME: Need a proper unit test for this -class lock_file: - def __init__(self, fp, mode): - '''Lock file pointed to by file pointer fp. - - This call is blocking. - ''' - - self._mode = mode - if isinstance(fp, int): - # Treat fp as a file descriptor - self._fd = fp - else: - self._fd = fp.fileno() - - def __enter__(self): - fcntl.flock(self._fd, self._mode) - - def __exit__(self, exc_type, exc_val, exc_tb): - fcntl.flock(self._fd, fcntl.LOCK_UN) - - def inpath(entry, pathvar): '''Check if entry is in path.