Trying to have a value that gets set in a method done in a multiprocess process get used by the ‘main’ process after it finishes.
It currently gives me
TypeError: 'str' object does not support item assignment
DID WE? ['']
Which, uh, isn’t really what I want given the following code:
def load_dat_site(d):
global seek_site
browser.execute_script("window.location = '"+seek_site+"';")
print "SITE LOADED"
d[0] = 'YEAH!'
manager = Manager()
d = manager.list([''])
site_load_process = multiprocessing.Process(target=load_dat_site, args=(d))
site_load_process.start()
site_load_process.join(15)
print "DID WE?", d
Is there any reason why example scripts seem to be able to set their lists’ values but this can’t?
From the
multiprocessing.Processdocumentation (emphasis added):Change your
multiprocessing.Processinstantiation to what is shown below and all will work as expected.There is a self-contained, working example here: http://ideone.com/VeTFYk
Remember that it is NOT the brackets/parens which make a tuple, it is the comma.