Created
May 20, 2017 21:45
-
-
Save dunossauro/67a8fb3700e3e078b501aeb2783f302b to your computer and use it in GitHub Desktop.
Vare diretórios usando Pool
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.dummy import Pool | |
from os import listdir | |
def list_print(path: str) -> tuple: | |
""" | |
Executa um listdir e retorna uma tupla com o path e os arquivos. | |
Args: | |
path: diretório a ser aplicada a função listdir | |
""" | |
return path, listdir(path) | |
nodes = Pool(4) | |
dir_paths = [el for el in listdir('.') if len(el.split('.')) == 1] | |
print(nodes.map(list_print, dir_paths)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment