import os
from glob import iglob
from concurrent.futures import ThreadPoolExecutor


def count_words_file(path):
    if not os.path.isfile(path):
        return 0
    with open(path) as file:
        return sum(len(line.split()) for line in file)


def count_words_sequential(pattern):
    return sum(map(count_words_file, iglob(pattern)))


def count_words_threading(pattern):
    with ThreadPoolExecutor() as pool:
        return sum(pool.map(count_words_file, iglob(pattern)))

[((7, 11, 7, 31), 'os.path.isfile', 'os.path.isfile', ({(7, 26, 7, 30): 'path'}, {}), '(path)', False, 'import os\n'), ((18, 9, 18, 29), 'concurrent.futures.ThreadPoolExecutor', 'ThreadPoolExecutor', ({}, {}), '()', False, 'from concurrent.futures import ThreadPoolExecutor\n'), ((14, 37, 14, 51), 'glob.iglob', 'iglob', ({(14, 43, 14, 50): 'pattern'}, {}), '(pattern)', False, 'from glob import iglob\n'), ((19, 46, 19, 60), 'glob.iglob', 'iglob', ({(19, 52, 19, 59): 'pattern'}, {}), '(pattern)', False, 'from glob import iglob\n')]