Last active
April 20, 2023 06:11
-
-
Save code-yeongyu/3f1ebf15178dc98de22fc52094ce6c0d to your computer and use it in GitHub Desktop.
Execute Functions in parallel easily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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