Answer the question
In order to leave comments, you need to log in
How to extract data from a child process?
As a result, I get 4 lists that need to be combined into 1, I tried queue, but it didn’t work, how can this be implemented?
f __name__ == '__main__':
print(len(m_id))
cpus = multiprocessing.cpu_count()
if length % cpus == 0:
pass
q_1 = multiprocessing.Queue()
proc_1 = Process(target=get_mes, args=(m_id[0:length//4],q_1))#m_id[0:length//2
proc_2 = Process(target=get_mes, args=(m_id[(length // 4)*2:(length // 4)*3],q_1))
proc_3 = Process(target=get_mes, args=(m_id[(length // 4)*3:(length // 4)*4],q_1))
proc_2.start()
print('2')
proc_3.start()
print('3')
proc_1.start()
print('1')
pr_1 = get_mes(m_id[length//2:(length//2)*2],0)
pr_2 = q_1.get()
pr_3 = q_1.get()
pr_4 = q_1.get()
all_mes = pr_1+pr_2+pr_3+pr_4
print(len(all_mes))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question