Skip to content

Instantly share code, notes, and snippets.

@jimjh
Created October 29, 2015 23:42
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 jimjh/ad357b77c39d1fda6614 to your computer and use it in GitHub Desktop.
Save jimjh/ad357b77c39d1fda6614 to your computer and use it in GitHub Desktop.
sharing state
def x():
# using a function as a convenient global object
print 'hello!'
x.favorite_band = 'Maroon 5'
def went_to_music_festival(s):
print 'favorite band was ' + x.favorite_band
x.favorite_band = s
print 'favorite band is ' + x.favorite_band
from multiprocessing import Pool
pool = Pool(processes=10)
pool.map(went_to_music_festival, ['Made In Heights', 'The Who'], 1)
print x.favorite_band
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment