diff options
| -rw-r--r-- | pyecsca/misc/utils.py | 2 | ||||
| -rw-r--r-- | pyproject.toml | 3 | ||||
| -rw-r--r-- | test/misc/__init__.py | 0 | ||||
| -rw-r--r-- | test/misc/test_utils.py | 17 |
4 files changed, 20 insertions, 2 deletions
diff --git a/pyecsca/misc/utils.py b/pyecsca/misc/utils.py index eb52614..51cbbba 100644 --- a/pyecsca/misc/utils.py +++ b/pyecsca/misc/utils.py @@ -7,7 +7,7 @@ from typing import List, Any, Generator from pyecsca.misc.cfg import getconfig, TemporaryConfig -from concurrent.futures import ProcessPoolExecutor, as_completed, Future +from loky import ProcessPoolExecutor, as_completed, Future def pexec(s): diff --git a/pyproject.toml b/pyproject.toml index 82242c0..bfe5286 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,8 @@ "numba", "networkx", "importlib-resources", - "anytree" + "anytree", + "loky" ] [project.urls] diff --git a/test/misc/__init__.py b/test/misc/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/misc/__init__.py diff --git a/test/misc/test_utils.py b/test/misc/test_utils.py new file mode 100644 index 0000000..72ce711 --- /dev/null +++ b/test/misc/test_utils.py @@ -0,0 +1,17 @@ + +from pyecsca.misc.utils import TaskExecutor + + +def run(a, b): + return a + b + + +def test_executor(): + with TaskExecutor(max_workers=2) as pool: + for i in range(10): + pool.submit_task(i, + run, + i, 5) + for i, future in pool.as_completed(): + res = future.result() + assert res == i + 5 |
