Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithread emoji download #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
from io import BytesIO
from multiprocessing.dummy import Pool
from os.path import expanduser
from pathlib import Path
from typing import Dict
Expand Down Expand Up @@ -171,14 +172,21 @@ def check_if_exists_map(self, args):
def get_custom_emoji(self):
data = self.slack.web_client.emoji_list()

work_pool = Pool(WORK_POOL_SIZE)

emoji_to_download = list(
filter(None, map(self.check_if_exists_map, data["emoji"].items()),)
filter(
None,
work_pool.imap_unordered(
self.check_if_exists_map, data["emoji"].items()
),
)
)
num_emoji = len(emoji_to_download)

list(
tqdm(
map(self.update_emoji_map, emoji_to_download),
work_pool.imap_unordered(self.update_emoji_map, emoji_to_download),
desc="Downloading Custom Emoji",
unit="emoji",
total=num_emoji,
Expand Down