-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blueetl_core.parallel.isolated()
Other: If the env variable ``BLUEETL_SUBPROCESS_LOGGING_LEVEL`` is empty or not defined, then the log level of the subprocesses is inherited from the parent.
- Loading branch information
1 parent
9a4d5ac
commit 8faab0b
Showing
4 changed files
with
72 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from functools import partial | ||
|
||
import pytest | ||
|
||
from blueetl_core import parallel as test_module | ||
|
||
|
||
def _myfunc(n): | ||
return n * n | ||
|
||
|
||
@pytest.mark.parametrize("jobs", [1, 3, None]) | ||
def test_run_parallel(jobs): | ||
tasks = [test_module.Task(partial(_myfunc, n=i)) for i in range(3)] | ||
result = test_module.run_parallel(tasks=tasks, jobs=jobs) | ||
assert result == [0, 1, 4] | ||
|
||
|
||
def test_isolated(): | ||
func = test_module.isolated(_myfunc) | ||
result = func(n=2) | ||
assert result == 4 |