Created
May 23, 2015 15:15
-
-
Save selfcommit/2334c0e32246cb0de1b1 to your computer and use it in GitHub Desktop.
This file contains 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
def _pickle_method(m): | |
# http://stackoverflow.com/questions/25156768/ | |
if m.im_self is None: | |
return getattr, (m.im_class, m.im_func.func_name) | |
else: | |
return getattr, (m.im_self, m.im_func.func_name) | |
copy_reg.pickle(types.MethodType, _pickle_method) | |
class UsefulWorkThings(object): | |
def _pool_helper(self, args): | |
return self.get_custom_fields(*args) | |
def enumerate_things(self): | |
"""returns a list of things gathered by web request""" | |
pool = Pool(processes=16) # how many threads we run at once | |
field_list = [] | |
employee_payload = [] | |
field_list.append('customField') | |
for employee in self.employees: | |
employee_tuple = (employee['id'], field_list) | |
employee_payload.append(employee_tuple) | |
try: | |
results = pool.map(self._pool_helper, iterable=employee_payload) | |
except Exception, e: | |
raise e | |
return results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment