Skip to content

Commit

Permalink
make progress to logger object optional
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewThe committed Dec 15, 2023
1 parent 4121adc commit edd18b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion job_pool/job_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(
queue: Optional[multiprocessing.Queue] = None,
timeout: int = 10000,
maxtasksperchild: Optional[int] = None,
write_progress_to_logger: bool = False,
):
"""Creates a JobPool object
Expand All @@ -84,6 +85,7 @@ def __init__(
"""
self.timeout = timeout
self.maxtasksperchild = maxtasksperchild
self.write_progress_to_logger = write_progress_to_logger

if not queue and multiprocessing.current_process().name != "MainProcess":
queue = multiprocessing.Queue()
Expand All @@ -106,7 +108,9 @@ def applyAsync(self, f, fargs, *args, **kwargs):
def checkPool(self, printProgressEvery: int = -1):
try:
outputs = list()
tqdm_out = TqdmToLogger(logger, level=logging.INFO)
tqdm_out = None
if self.write_progress_to_logger:
tqdm_out = TqdmToLogger(logger, level=logging.INFO)
for res in tqdm(
self.results,
file=tqdm_out,
Expand Down

0 comments on commit edd18b8

Please sign in to comment.