Skip to content Skip to sidebar Skip to footer

Valueerror: Too Many Values To Unpack Multiprocessing Pool

I have the following 'worker' that initially returned a single JSON object, but I would like it to return multiple JSON objects: def data_worker(data): _cats, index, total = da

Solution 1:

First of all I think you meant to write this:

cats, breeds = pool.map(data_worker, data, chunksize=1)

But anyway this won't work, because data_worker returns a pair, but map() returns a list of whatever the worker returns. So you should do this:

cats = []
breeds = []
for cat, breed in pool.map(data_worker, data, chunksize=1):
    cats.append(cat)
    breeds.append(breed)

This will give you the two lists you seek.

In other words, you expected a pair of lists, but you got a list of pairs.

Post a Comment for "Valueerror: Too Many Values To Unpack Multiprocessing Pool"