0

Why the processing is locked after excuting Queue().put and Queue().get in multiprocessing? And if the array is small like np.ones((2, 2)), the program works well. It looks weird. How to solve it when the array is large?

import multiprocessing as mp
import numpy as np

def solve(queue):
    for i in range(3):
        queue.put(np.ones((20, 20)))
        print('put')

def func():
    jobs = []
    queue = mp.Queue()

    for i in range(5):
        p = mp.Process(target=solve, args=(queue,))
        jobs.append(p)
        p.start()
        print('start')

    for j in jobs:
        j.join()

    print('end')

if __name__ == '__main__':
    func()
BONNED
  • 23
  • 1
  • 5
  • 1
    You are attempting to `join` the child processes without first retrieving the items they have placed on the queue. – Booboo Sep 03 '22 at 18:12

0 Answers0