Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions reframe/frontend/autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#
# SPDX-License-Identifier: BSD-3-Clause

import fcntl
import json
import jsonschema
import os
Expand Down Expand Up @@ -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}'
Expand All @@ -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}'
Expand Down
23 changes: 0 additions & 23 deletions reframe/utility/osext.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import collections.abc
import errno
import fcntl
import getpass
import grp
import os
Expand Down Expand Up @@ -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.

Expand Down