Use threadpool add_many for creating job batch.

This commit is contained in:
voussoir 2020-02-12 19:32:11 -08:00
parent cb9d119482
commit 0a12dd45c0

View file

@ -186,10 +186,11 @@ def download_bigchunk_range(bigchunk_xy1, bigchunk_xy2, threads=1):
else: else:
pool = threadpool.ThreadPool(size=threads) pool = threadpool.ThreadPool(size=threads)
jobs = [] kwargss = [
for (x, y) in bigchunks: {'function': download_bigchunk, 'args': (x, y), 'name': (x, y),}
job = pool.add(download_bigchunk, args=(x, y), name=(x, y)) for (x, y) in bigchunks
jobs.append(job) ]
jobs = pool.add_many(kwargss)
for job in jobs: for job in jobs:
job.join() job.join()
if job.exception: if job.exception: