Created
July 25, 2014 09:58
-
-
Save phihag/f96e4a38cf8702077a47 to your computer and use it in GitHub Desktop.
Test program for http://stackoverflow.com/q/24952918/35070
This file contains hidden or 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
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