Skip to content

Commit

Permalink
Add maximum_refresh_time to run_tasks()
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jul 5, 2024
1 parent d19a788 commit bbb892d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions audeer/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ def run_tasks(
multiprocessing: bool = False,
progress_bar: bool = False,
task_description: str = None,
maximum_refresh_time: float = None,
) -> typing.Sequence[typing.Any]:
r"""Run parallel tasks using multprocessing.
Expand All @@ -562,6 +563,11 @@ def run_tasks(
progress_bar: show a progress bar
task_description: task description
that will be displayed next to progress bar
maximum_refresh_time: refresh the progress bar
at least every ``maximum_refresh_time`` seconds,
using another thread.
If ``None``,
no refreshing is enforced
Examples:
>>> power = lambda x, n: x**n
Expand All @@ -578,6 +584,7 @@ def run_tasks(
params,
total=len(params),
desc=task_description,
maximum_refresh_time=maximum_refresh_time,
disable=not progress_bar,
) as pbar:
for index, param in enumerate(pbar):
Expand All @@ -592,6 +599,7 @@ def run_tasks(
with audeer_progress_bar(
total=len(params),
desc=task_description,
maximum_refresh_time=maximum_refresh_time,
disable=not progress_bar,
) as pbar:
futures = []
Expand Down

0 comments on commit bbb892d

Please sign in to comment.