Skip to content

Commit b20173a

Browse files
committed
TST: Add test to simulate running update() simultaneously
1 parent b3b0846 commit b20173a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from concurrent.futures import ProcessPoolExecutor
3+
4+
import pytest
5+
6+
CPUs = os.cpu_count() or 1
7+
8+
9+
def _update():
10+
from templateflow.conf import update
11+
12+
update(local=False, overwrite=True, silent=True)
13+
return True
14+
15+
@pytest.mark.skipif(CPUs < 2, reason='At least 2 CPUs are required')
16+
def test_multi_proc_update(tmp_path, monkeypatch):
17+
tf_home = tmp_path / 'tf_home'
18+
monkeypatch.setenv('TEMPLATEFLOW_HOME', str(tf_home))
19+
20+
futs = []
21+
with ProcessPoolExecutor(max_workers=2) as executor:
22+
for _ in range(2):
23+
futs.append(executor.submit(_update))
24+
25+
for fut in futs:
26+
assert fut.result()

0 commit comments

Comments
 (0)