diff --git a/conservancy_beancount/tools/audit_report.py b/conservancy_beancount/tools/audit_report.py index b5e2670b4cef50e5b4fee90c3ac177dd7344501c..428185d33ddee955dd1f8242dc9b974d7414518c 100644 --- a/conservancy_beancount/tools/audit_report.py +++ b/conservancy_beancount/tools/audit_report.py @@ -15,9 +15,9 @@ # along with this program. If not, see . import argparse +import concurrent.futures as futmod import datetime import logging -import multiprocessing import os import runpy import sys @@ -198,10 +198,10 @@ def main(arglist: Optional[Sequence[str]]=None, logger.critical("no books available to load") return os.EX_NOINPUT - with multiprocessing.Pool(args.jobs, maxtasksperchild=1) as pool: + with futmod.ProcessPoolExecutor(args.jobs) as pool: logger.debug("%s: process pool ready with %s workers", now_s(), args.jobs) fy_paths = books._iter_fy_books(fy.range(args.audit_year - 1, args.end_date)) - check_results = pool.imap_unordered(bean_check, fy_paths) + check_results = pool.map(bean_check, fy_paths) if all(exitcode == 0 for exitcode in check_results): logger.debug("%s: bean-check passed", now_s()) else: @@ -214,10 +214,10 @@ def main(arglist: Optional[Sequence[str]]=None, return os.EX_DATAERR report_results = [ - pool.apply_async(report_func, (arglist,), {'config': config}) + pool.submit(report_func, arglist, config=config) for report_func, arglist in reports ] - report_errors = [res.get() for res in report_results if res.get() != 0] + report_errors = [res.result() for res in report_results if res.result() != 0] if not report_errors: logger.debug("%s: all reports generated", now_s()) else: