Skip to content

Instantly share code, notes, and snippets.

@kylewu
Created April 17, 2018 18:40
Show Gist options
  • Save kylewu/d6a7900a7cd0818749c291e921d506b7 to your computer and use it in GitHub Desktop.
Save kylewu/d6a7900a7cd0818749c291e921d506b7 to your computer and use it in GitHub Desktop.
multiprocessing pool
from multiprocessing import Pool
class Test(object):
def __init__(self):
self.array = []
def task(self, n):
self.array.append(n)
print(self.array)
def run(self):
p = Pool(4)
p.map(self.task, [1, 2, 3, 4])
Test().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment