Skip to content

Commit 9da6675

Browse files
committed
Re-configure to cancel futures when an exception including KeyboardInterrupt is encountered.
1 parent 9130ba7 commit 9da6675

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

distributions/process.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
@main
1616
def run():
1717
res = pypi.Distribution.unprocessed()
18-
with concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count()) as executor:
19-
futures = (executor.submit(dist.process) for dist in res.dists)
20-
completes = concurrent.futures.as_completed(futures)
18+
executor = concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count())
19+
futures = (executor.submit(dist.process) for dist in res.dists)
20+
completes = concurrent.futures.as_completed(futures)
21+
try:
2122
consume(tqdm.tqdm(completes, total=res.count, smoothing=0.1))
23+
finally:
24+
executor.shutdown(wait=True, cancel_futures=True)

0 commit comments

Comments
 (0)