I have this code:
alphabet = string.digits + string.letters
for key in itertools.product(alphabet, repeat=6):
if __name__ == '__main__':
jobs = 
for i in range(4):
p = multiprocessing.Process(target=loop)
You need to divide the workload beforehand and pass it in to your function when you call
Process. Generally speaking, this can be a hard problem, but in your case it's pretty trivial since you're just generating cartesian products -- simply slice off the first character and attach it separately.
i.e. instead of generating
repeat=5 and iterate through the possibilities for the first letter yourself, passing each to a separate process.
def loop(first, sequence): for seq in sequence: key = first + seq ....
and call it with:
alphabet = ... for letter in alphabet: p = Process(target=loop, args=(letter, itertools.product(alphabet, repeat=5)) # etc.
This will spawn one process per letter in your alphabet; you could do exactly four splits or other things like that by passing ranges for the first character, too.