Created
April 21, 2013 03:19
-
-
Save vchahun/5428328 to your computer and use it in GitHub Desktop.
Multiprocessing example
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 | |
data1 = None | |
data2 = None | |
def load_data(): | |
global data1, data2 | |
data1 = 1 # read some data | |
data2 = 1 # read more data | |
def train_classifier(word): | |
global data1, data2 # if you need to use these | |
# etc. | |
# write model to disk | |
def main(): | |
pool = mp.Pool(10, load_data) | |
words = ['my', 'name', 'is', 'manaal'] | |
pool.map(train_classifier, words) | |
if __name__ == '__main___': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment