diff options
| author | Adam Janovsky | 2021-11-16 12:36:53 +0100 |
|---|---|---|
| committer | Adam Janovsky | 2021-11-16 12:36:53 +0100 |
| commit | e9b83ebcf570bab4fb8d12077e390f8f2c7df279 (patch) | |
| tree | c4645a9088f7cf70eba982caadf50e80d2572142 /sec_certs/parallel_processing.py | |
| parent | 1952677dce269dd165bf75f169b1e456e3bb339a (diff) | |
| download | sec-certs-e9b83ebcf570bab4fb8d12077e390f8f2c7df279.tar.gz sec-certs-e9b83ebcf570bab4fb8d12077e390f8f2c7df279.tar.zst sec-certs-e9b83ebcf570bab4fb8d12077e390f8f2c7df279.zip | |
just rewrite some ifs to cond. expres.
Diffstat (limited to 'sec_certs/parallel_processing.py')
| -rw-r--r-- | sec_certs/parallel_processing.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/sec_certs/parallel_processing.py b/sec_certs/parallel_processing.py index 20a82f32..40025074 100644 --- a/sec_certs/parallel_processing.py +++ b/sec_certs/parallel_processing.py @@ -7,15 +7,9 @@ import time def process_parallel(func: Callable, items: Iterable, max_workers: int, callback: Optional[Callable] = None, use_threading: bool = True, progress_bar: bool = True, unpack: bool = False, progress_bar_desc: Optional[str] = None): - if use_threading is True: - pool = ThreadPool(max_workers) - else: - pool = Pool(max_workers) - 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] + pool = ThreadPool(max_workers) if use_threading else Pool(max_workers) + results = [pool.apply_async(func, (*i,), callback=callback) for i in items] if unpack else [pool.apply_async(func, (i, ), callback=callback) for i in items] if progress_bar is True and items: bar = tqdm(total=len(results), desc=progress_bar_desc) |
