Skip to content

Instantly share code, notes, and snippets.

@phihag
Created July 25, 2014 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phihag/f96e4a38cf8702077a47 to your computer and use it in GitHub Desktop.
Save phihag/f96e4a38cf8702077a47 to your computer and use it in GitHub Desktop.
import multiprocessing as mp
def worker(filex):
""" reading lots of data """
raw = filter(lambda x: len(x.split())>3,
open(filex).readlines())
data = {}
# putting all the data in the data dictionary
return data
# multiprocessing options
nproc = mp.cpu_count()
pool = mp.Pool(processes=nproc)
files_to_parse = ['/etc/passwd', '/etc/hosts']
traj = pool.map(worker, tuple(files_to_parse))
pool.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment