Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Created May 20, 2017 21:45
Show Gist options
  • Save dunossauro/67a8fb3700e3e078b501aeb2783f302b to your computer and use it in GitHub Desktop.
Save dunossauro/67a8fb3700e3e078b501aeb2783f302b to your computer and use it in GitHub Desktop.
Vare diretórios usando Pool
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