-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from mgxd/fix/zip-extract-race-condition
FIX: Avoid directory clobber during zip extraction
- Loading branch information
Showing
5 changed files
with
76 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
from concurrent.futures import ProcessPoolExecutor | ||
|
||
import pytest | ||
|
||
CPUs = os.cpu_count() or 1 | ||
|
||
|
||
def _update(): | ||
from templateflow.conf import update | ||
|
||
update(local=False, overwrite=True, silent=True) | ||
return True | ||
|
||
|
||
@pytest.mark.skipif(CPUs < 2, reason='At least 2 CPUs are required') | ||
def test_multi_proc_update(tmp_path, monkeypatch): | ||
tf_home = tmp_path / 'tf_home' | ||
monkeypatch.setenv('TEMPLATEFLOW_HOME', str(tf_home)) | ||
|
||
futs = [] | ||
with ProcessPoolExecutor(max_workers=2) as executor: | ||
for _ in range(2): | ||
futs.append(executor.submit(_update)) | ||
|
||
for fut in futs: | ||
assert fut.result() |