Skip to content

Instantly share code, notes, and snippets.

@selfcommit
Created May 23, 2015 15:15
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 selfcommit/2334c0e32246cb0de1b1 to your computer and use it in GitHub Desktop.
Save selfcommit/2334c0e32246cb0de1b1 to your computer and use it in GitHub Desktop.
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