Skip to content

Instantly share code, notes, and snippets.

@vchahun
Created April 21, 2013 03:19
Show Gist options
  • Save vchahun/5428328 to your computer and use it in GitHub Desktop.
Save vchahun/5428328 to your computer and use it in GitHub Desktop.
Multiprocessing example
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