Skip to content
Advertisement

create threads within processes and share a queue between the threads

I am trying to create 3 threads within each of 2 processes and share a queue of the type multiprocessing.JoinableQueue among all threads. The worker_func function simply creates the threads while the thread_func function prints out the values it gets from the queue. The program gets stuck somewhere in the time.sleep or in the get() method of queue. What am I doing wrong? I am running on a Windows computer.

JavaScript

Advertisement

Answer

You are not allowing the threads to complete their work. Either set them as non-daemon, or explicitly wait for them to join:

JavaScript
Advertisement