def main(source, num_threads):
    pool = futures.ThreadPoolExecutor(num_threads)
    pending = {}
    t0 = time.time()
    # submit all jobs
    for iso_cc in sorted(cf.cc2name):
        print('get:', iso_cc)
        times[iso_cc] = [time.time() - t0]
        job = pool.submit(fetch, iso_cc, source)
        pending[job] = iso_cc
    to_download = len(pending)
    downloaded = 0
    # get results as jobs are done
    for job in futures.as_completed(pending, timeout=GLOBAL_TIMEOUT):
        try:
            octets, file_name = job.result()
            times[pending[job]].append(t0 - time.time())
            downloaded += 1
            print('\t--> {}: {:5d} bytes'.format(file_name, octets))
        except Exception as exc:
            print('\t***', pending[job], 'generated an exception:', exc)
    ratio = downloaded / to_download
    print('{} of {} downloaded ({:.1%})'.format(downloaded, to_download, ratio))
    for iso_cc in sorted(times):
        start, end = times[iso_cc]
        print('{}\t{:.6g}\t{:.6g}'.format(iso_cc, start, end))
dataset/ETHPy150Open fluentpython/example-code/attic/concurrency/flags/getthreadpool.py/main/swapped operands of `-`