diff options
| author | J08nY | 2024-04-08 14:24:16 +0200 |
|---|---|---|
| committer | J08nY | 2024-04-08 14:24:16 +0200 |
| commit | 372631bcd588c66b47746e138f8d4d08d9d71e29 (patch) | |
| tree | 39a0ecd8cdfe206992ffd557d29d34c146fbe7b7 /pyecsca/misc | |
| parent | b6cedf2e68204a6b9e7988da10bb8cd81678b171 (diff) | |
| download | pyecsca-372631bcd588c66b47746e138f8d4d08d9d71e29.tar.gz pyecsca-372631bcd588c66b47746e138f8d4d08d9d71e29.tar.zst pyecsca-372631bcd588c66b47746e138f8d4d08d9d71e29.zip | |
Improve tree building with more quantities.
Diffstat (limited to 'pyecsca/misc')
| -rw-r--r-- | pyecsca/misc/utils.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pyecsca/misc/utils.py b/pyecsca/misc/utils.py index 8e313a3..e525fe0 100644 --- a/pyecsca/misc/utils.py +++ b/pyecsca/misc/utils.py @@ -1,9 +1,10 @@ """Just some utilities I promise.""" import sys from ast import parse +from contextlib import contextmanager from typing import List, Any, Generator -from ..misc.cfg import getconfig +from ..misc.cfg import getconfig, TemporaryConfig from concurrent.futures import ProcessPoolExecutor, as_completed, Future @@ -42,8 +43,17 @@ def warn(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) +@contextmanager +def silent(): + """Temporarily disable output.""" + with TemporaryConfig() as cfg: + cfg.log.enabled = False + yield + + class TaskExecutor(ProcessPoolExecutor): """A simple ProcessPoolExecutor that keeps tracks of tasks that were submitted to it.""" + keys: List[Any] futures: List[Future] @@ -67,4 +77,4 @@ class TaskExecutor(ProcessPoolExecutor): i = self.futures.index(future) yield self.keys[i], future self.futures = [] - self.keys = []
\ No newline at end of file + self.keys = [] |
