I have been banging my head against Multiprocessing in Python for the better part of the day now, and I've managed to make very little progress - I apologize if my question is a duplicate or my ignorance is apparent - I couldn't find it asked anywhere else in this way.
I'm looking for a way to run functions in parallel, and return some arbitrary thing they've produced back to the main script.
The question is: Can a Process() started from Multiprocessing return a list or some other arbitrary variable type?
For example, I would like to:
def 30_second_function():
#pretend this takes 30 seconds to run
return ["mango", "habanero", "salsa"]
#End 30_second_function()
def 5_second_function():
#pretend this takes 5 seconds to run
return {"beans": "8 oz", "tomato paste": "16 oz"}
#End 5_second_function()
p1 = multiprocessing.Process(target=30_second_function)
p1.start()
p2 = multiprocessing.Process(target=5_second_function)
p2.start()
#Somehow retrieve the list and the dictionary here. p1.returned??
And then somehow access the list from 30_second_function and the dictionary from 5_second_function. Is this possible? Am I going about this the wrong way?