# Lock-file access error, define location of lockfiles?

**URL:** <https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759>\
**Category:** Support & Discussions\
**Created:** [March 19, 2026, 10:24am UTC](https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759 "2026-03-19T10:24:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skjerns](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/skjerns/32/1731_2.png) [@skjerns](https://mne.discourse.group/u/skjerns)\
**Post date:** [March 19, 2026, 10:24am UTC](https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759/1 "2026-03-19T10:24:01Z")

</div>

I’m running a power analysis on a cluster which spawns \>100 processes running `mne.stats.permutation_t_test` in long loops.

I’m getting an error related to a file lock once in a while

```python
/xxx/anaconda3/envs/default/lib/python3.13/contextlib.py:141: RuntimeWarning: Could not acquire lock file after 5 seconds, consider deleting it if you know the corresponding file is usable:
/%HOME%/.mne/mne-python.json.lock

```

I don’t really understand where the process iis using the file lock, seems to be somewhere deeper inside the code?

However, the culprit is probably our network drive on which the $HOME is hosted, which sometimes has access delays. As I’m running on a cluster, the home is only accessible via network.

Is there any way to tell MNE where to store configs, e.g. with an env var? Or not use the lock files? If I could define a lockfile for each process independently that would be fine.

according to Claude Code investigation it is called here:

```python

  The chain is:                                                                                                                                                                           
  permutation_t_test (line 90)                                                                                                                                                            
    → parallel_func (parallel.py:95)                                                                                                                                                      
      → get_config("MNE_CACHE_DIR")                                                                                                                                                       
        → _load_config → _open_lock (utils/config.py:257)
          → filelock.FileLock(..., timeout=5) ← warning thrown here

```

---

<div class="post-metadata">

**Author:** ![skjerns](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/skjerns/32/1731_2.png) [@skjerns](https://mne.discourse.group/u/skjerns)\
**Post date:** [March 19, 2026, 10:45am UTC](https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759/2 "2026-03-19T10:45:50Z")

</div>

I found the culprit! `n_jobs=None` is not equivalent to setting `n_jobs=1` , even though it’s advertised as such!

Internally, the whole `parallel_func` chain is triggered when `n_jobs=None`, whereas it is skipped with `n_jobs=1`. Therefore, the config is loaded to check for `MNE_CACHE_DIR`, which isn’t necessary anyway because n\_jobs is None.

Not sure if this is a bug or intended behaviour?

---

<div class="post-metadata">

**Author:** ![tsbinns](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/tsbinns/32/4543_2.png) [@tsbinns](https://mne.discourse.group/u/tsbinns)\
**Post date:** [March 19, 2026, 11:10am UTC](https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759/3 "2026-03-19T11:10:53Z")

</div>

The `n_jobs` description for `mne.stats.permutation_t_test` says:

> `None` (default) is a marker for ‘unset’ that will be interpreted as `n_jobs=1` (sequential execution) unless the call is performed under a `joblib.parallel_config` context manager that sets another value for `n_jobs`.

Is the `mne.stats.permutation_t_test` call being made under a `joblib.parallel_config` context manager? If so, I’d say this isn’t a bug, otherwise could be worth looking into.

---

<div class="post-metadata">

**Author:** ![skjerns](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/skjerns/32/1731_2.png) [@skjerns](https://mne.discourse.group/u/skjerns)\
**Post date:** [March 19, 2026, 12:08pm UTC](https://mne.discourse.group/t/lock-file-access-error-define-location-of-lockfiles/11759/4 "2026-03-19T12:08:45Z")

</div>

Nope, no joblib.parallel\_config

i’ve opened an issue here: [GitHub · Where software is built](https://github.com/mne-tools/mne-python/issues/13770)
