Skip to content

Instantly share code, notes, and snippets.

@code-yeongyu
Last active April 20, 2023 06:11
Show Gist options
  • Save code-yeongyu/3f1ebf15178dc98de22fc52094ce6c0d to your computer and use it in GitHub Desktop.
Save code-yeongyu/3f1ebf15178dc98de22fc52094ce6c0d to your computer and use it in GitHub Desktop.
Execute Functions in parallel easily
from multiprocessing import cpu_count
from multiprocessing.dummy import Pool
from typing import Any, Callable, Iterable
def execute_parallel(
func: Callable[..., Any],
args: Iterable[tuple[Any, ...]],
) -> None:
pool = Pool(cpu_count())
pool.starmap(func, args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment