diff options
| author | adamhrv <adam@ahprojects.com> | 2019-02-13 00:13:26 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-02-13 00:13:26 +0100 |
| commit | b886a642be3e7486d487668b9319799b2d5a8551 (patch) | |
| tree | 793c9bd7feea3776da6ef0b31eace4d894c47620 /megapixels/commands | |
| parent | d9f5999e5dec73b82641bd41fd8e9a38b3f2f57e (diff) | |
clean up
Diffstat (limited to 'megapixels/commands')
| -rw-r--r-- | megapixels/commands/templates/multithreaded.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/megapixels/commands/templates/multithreaded.py b/megapixels/commands/templates/multithreaded.py index fec3dac4..a9b287f8 100644 --- a/megapixels/commands/templates/multithreaded.py +++ b/megapixels/commands/templates/multithreaded.py @@ -2,9 +2,9 @@ import click @click.command() @click.option('-i', '--input', 'opt_fp_in', required=True, - help='Input file') + help='Input') @click.option('-o', '--output', 'opt_fp_out', required=True, - help='Output file') + help='Output') @click.option('-t', '--threads', 'opt_threads', default=4, help='Number of threads') @click.pass_context @@ -22,28 +22,27 @@ def cli(ctx, opt_fp_in, opt_fp_out, opt_threads): log.info('multithreaded template') # setup multithreading function - def pool_process(data_obj): + def pool_process(item): # threaded function - global parse_yt_page results = [] try: - # do something here with data_obj + # do something here with item except Exception as e: log.debug(f'Error: {e}') pbar.update(1) return results # setup multithreading data holds - items = [] # list of dicts to process - results = [] - num_items = len(items) + pool_items = [] # list of dicts to process + pool_results = [] + num_items = len(pool_items) # run the multithreading with progress bar pbar = tqdm(total=num_items) pool_process = partial(pool_process) pool = ThreadPool(opt_threads) with tqdm(total=num_items) as pbar: - results = pool.map(pool_process, media_items) + pool_results = pool.map(pool_process, pool_items) pbar.close() |
