Created
January 13, 2021 03:02
-
-
Save ZephyrBlu/058b776b4fad94f8147e6c0322ae418b to your computer and use it in GitHub Desktop.
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 pathlib import Path | |
from multiprocessing import Pool | |
from sc2_tournament_analysis import recursive_parse | |
from zephyrus_sc2_parser import parse_replay | |
def handle_replay(path, player_names, identifiers): | |
replay = parse_replay(path) | |
# do stuff and then return the data you want | |
# required for multiprocessing | |
if __name__ == '__main__': | |
results = [] | |
replays = Path('replays') | |
replay_paths = recursive_parse( | |
sub_dir=replays, | |
# data_function is unused with multiprocessing, but required | |
data_function=handle_replay, | |
# this means you get a list of paths instead of synchronous parsing | |
multi=True, | |
) | |
# Pool multiprocessing for better throughput of parsing | |
with Pool(10) as p: | |
results = p.starmap(handle_replay, replay_paths) | |
# do stuff with aggregated data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment