Skip to content

Commit 8089f2c

Browse files
updating the _fileio.py
1 parent f8d868b commit 8089f2c

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

mne_bids/_fileio.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ def _get_lock_context(path):
4848

4949
if filelock:
5050
try:
51-
# Use FileLock (not SoftFileLock) for inter-process synchronization
52-
# SoftFileLock is more lenient but doesn't prevent concurrent writes
53-
# Timeout of 30 seconds prevents indefinite blocking
54-
# We use a wrapper to handle the lock lifecycle better
55-
lock_obj = filelock.FileLock(lock_path, timeout=30)
51+
lock_obj = filelock.FileLock(lock_path, timeout=30) # timeout in seconds
5652
lock_context = _FileLockContext(lock_obj)
5753
have_lock = True
5854
backend = "filelock"
@@ -108,12 +104,8 @@ def _open_lock(path, *args, **kwargs):
108104
return
109105

110106
lock_context, lock_path, have_lock, backend = _get_lock_context(path)
111-
try:
112-
with lock_context, open(path, *args, **kwargs) as fid:
113-
yield fid
114-
finally:
115-
if have_lock:
116-
_cleanup_lock_file(lock_path, backend)
107+
with lock_context, open(path, *args, **kwargs) as fid:
108+
yield fid
117109

118110

119111
@contextmanager
@@ -136,19 +128,3 @@ def _file_lock(path):
136128
finally:
137129
if token is not None:
138130
_LOCKED_PATHS.reset(token)
139-
if have_lock:
140-
_cleanup_lock_file(lock_path, backend)
141-
142-
143-
def _cleanup_lock_file(lock_path: Path, backend: str | None) -> None:
144-
"""Cleanup lock file - but don't manually delete for FileLock.
145-
146-
For FileLock, the library manages the lock file lifecycle automatically.
147-
We should NOT manually delete it as this causes race conditions when
148-
multiple processes try to delete the same file simultaneously.
149-
150-
The lock file will be cleaned up by the OS eventually.
151-
"""
152-
# Don't manually delete filelock's lock files - let the library manage them
153-
# If we need to clean up stale lock files, do it only at process startup
154-
pass

0 commit comments

Comments
 (0)