def initPool():
    global _haystack
_haystack = getHayStack()

def runMatch(args):
    global _haystack
hayCompanies = _haystack
if __name__ == '__main__':
    pool = Pool(processes=numProcesses, initializer=initPool)
Python multiprocess with pool workers - memory use optimization