diff options
| author | Adam Janovsky | 2021-02-19 17:39:09 +0100 |
|---|---|---|
| committer | Adam Janovsky | 2021-02-19 17:39:09 +0100 |
| commit | fccf787c1ddca5ffd4095ef1c3cb99f8feb8c78a (patch) | |
| tree | eb4efbf290c09c89362d9713bb3d5a598d833f9e | |
| parent | 0fb1b04a6fbb172db6682380be34a44d68197ba3 (diff) | |
| download | sec-certs-fccf787c1ddca5ffd4095ef1c3cb99f8feb8c78a.tar.gz sec-certs-fccf787c1ddca5ffd4095ef1c3cb99f8feb8c78a.tar.zst sec-certs-fccf787c1ddca5ffd4095ef1c3cb99f8feb8c78a.zip | |
Improves parallel processing function
- Adds option to unpack arguments
| -rw-r--r-- | sec_certs/cert_processing.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sec_certs/cert_processing.py b/sec_certs/cert_processing.py index 739bfa9f..b5519aab 100644 --- a/sec_certs/cert_processing.py +++ b/sec_certs/cert_processing.py @@ -5,13 +5,16 @@ import time def process_parallel(func: Callable, items: Iterable, max_workers: int, callback: Optional[Callable] = None, - use_threading: bool = True, progress_bar: bool = True): + use_threading: bool = True, progress_bar: bool = True, unpack: bool = False): if use_threading is True: pool = ThreadPool(max_workers) else: pool = Pool(max_workers) - results = [pool.apply_async(func, (i, ), callback=callback) for i in items] + if unpack is False: + results = [pool.apply_async(func, (i, ), callback=callback) for i in items] + else: + results = [pool.apply_async(func, (*i, ), callback=callback) for i in items] if progress_bar is True: bar = tqdm(total=len(results)) |
