nice to meet you, let me show you a simplified code first
from multiprocessing import Pool
AAA = []
def input_list():
with open('./AAA.tsv') as f:
for line in f:
AAA.append(line[:9])
return AAA
def printf(number):
print(AAA)
if __name__ == '__main__':
input_list()
pool = Pool(processes=1)
pool.map(printf, range(0, AAA.__len__()))
this is done, the AAA executed due to input_list will be It is not recognized in printf method.
However, if you declare input_list() outside,
from multiprocessing import Pool
AAA = []
def input_list():
with open('./AAA.tsv') as f:
for line in f:
AAA.append(line[:9])
return AAA
def printf(number):
print(AAA)
input_list()
if __name__ == '__main__':
pool = Pool(processes=1)
pool.map(printf, range(0, AAA.__len__()))
It works properly. Why does this happen?