I am quite new to Python multiprocessing concept.
I am trying to call function magicFunction which has multiple argument out of which first is iterable while all other are non-iterable. Also, it returns multiple value, let us say x, y, z
I am trying to figure out how to use executor here. Here is my approach, which is obviously wrong.
def magicFunction(webElem, uid_list, ignoreTagsList):
..
..
return x,y,z
with concurrent.futures.ProcessPoolExecutor() as executor:
for webElem, x_val, y_val, z_val in zip(webElem_list, executor.map(magicFunction, webElem_list, uid_list, ignoreTagsList)):
..
..
print("Values:", x_val, y_val, z_val)
Can someone suggest correct way to do this ?
You could use a class:
class FunctionReturn:
x = 0
y = 0
z = 0
def myFunction():
output = FunctionReturn()
output.x = 1
output.y = 2
output.z = 3
return output
data = myFunction()
print(data.x , data.y , data.z)
This will print 1 2 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With