name two lists A, B
I'd like to delete the B list elements from A list.
Python code not using multiprocessing
A = ["leo", "kiki", "eden"]
B = ["eden", "kiki"]
for i in B:
A.remove(i)
The multi-processing code that I thought of is as follows.
from multiprocessing import Pool
import time
A = ["leo", "kiki", "eden"]
B = ["eden", "kiki"]
def test(i):
global A
A.remove(i)
print("intest : ",A)
if __name__ == '__main__':
global A
pool = Pool(processes=2)
pool.map(test ,B)
pool.close()
pool.join()
print("final : ",A)
output results :
intest : ['leo', 'kiki']
intest : ['leo']
final : ['leo', 'kiki', 'eden']
why in "intest" The global variable applies correctly.
in "final" the global variable change is not applies?
Please give me a lot of help.
multiprocessingtypes such as Queues andshared_memoryblocks.multiprocessing. I think your question here is maybe oversimplified? :)