I'm trying to pass some user input from main or outside main to the function running inside a multiprocessing pool. Code is something like below:
import multiprocessing
global var1
var1 = input("enter input: ")
def function1(arg1_A):
x = var1 + 'string'
do stuff
def MCprocess():
pool = multiprocessing.Pool(4)
pool.map(function1, listarg1)
if __name__ == '__main__':
MCprocess()
Where do I put the input() function in order for all instances of function1 to receive it? Is there a better way of doing this?
To clarify. I've tried declaring var1 as global var1 within the function. That hasn't worked.
modulesmodule do and what isarg1? also could you say what you mean by "that hasn't worked". also ismultiprocessingcan be OS dependant, which OS do you care about. see stackoverflow.com/help/mcve