if __name__ == '__main__':
    totalTargets = len(getTargets('all'))
targetsPerBatch = totalTargets / numProcesses
processes = [Process(target=runMatch, args=(targetsPerBatch, range(0,
    totalTargets, targetsPerBatch))) for _ in range(numProcesses)]
for p in processes:
    p.start()
for p in processes:
    p.join()
Python multiprocess with pool workers - memory use optimization