From 0cfcab7fb2ca7f191c824960b57594b962cd9ca3 Mon Sep 17 00:00:00 2001 From: calum-chamberlain Date: Tue, 9 Jan 2024 11:03:08 +1300 Subject: [PATCH] try to add progressbar --- rt_eqcorrscan/database/database_manager.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rt_eqcorrscan/database/database_manager.py b/rt_eqcorrscan/database/database_manager.py index 57ff957..67416f9 100644 --- a/rt_eqcorrscan/database/database_manager.py +++ b/rt_eqcorrscan/database/database_manager.py @@ -128,9 +128,15 @@ def _summarize_template( return out -def _chunksize(n_tasks: int, max_workers: int = None) -> int: +def _chunksize( + n_tasks: int, + max_workers: int = None, + divisor: int = 100, # Used to give more up-to-date progress reports +) -> int: max_workers = max_workers or cpu_count() - return n_tasks // (max_workers - 1) + chunksize = n_tasks // (max_workers - 1) + chunksize //= divisor + return chunksize def _workers(executor) -> int: