Skip to content

Commit 4b39d29

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
16+
@pytest.mark.skipif(CPUs < 2, reason='At least 2 CPUs are required')
17+
def test_multi_proc_update(tmp_path, monkeypatch):
18+
tf_home = tmp_path / 'tf_home'
19+
monkeypatch.setenv('TEMPLATEFLOW_HOME', str(tf_home))
20+
21+
futs = []
22+
with ProcessPoolExecutor(max_workers=2) as executor:
23+
for _ in range(2):
24+
futs.append(executor.submit(_update))
25+
26+
for fut in futs:
27+
assert fut.result()

0 commit comments

Comments
 (0)