Skip to content

Commit 7cb1566

Browse files
cleaning the lock
1 parent 43586bd commit 7cb1566

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mne_bids/_fileio.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,15 @@ def _open_lock(path, *args, lock_timeout=None, **kwargs):
155155
canonical_path,
156156
timeout=lock_timeout,
157157
) as lock_context:
158-
with lock_context:
159-
if args or kwargs:
160-
with open(canonical_path, *args, **kwargs) as fid:
161-
yield fid
162-
else:
163-
yield None
158+
try:
159+
with lock_context:
160+
if args or kwargs:
161+
with open(canonical_path, *args, **kwargs) as fid:
162+
yield fid
163+
else:
164+
yield None
165+
finally:
166+
cleanup_lock_files(canonical_path)
164167
finally:
165168
with _ACTIVE_LOCKS_GUARD:
166169
_ACTIVE_LOCKS[lock_key] -= 1

0 commit comments

Comments
 (0)