Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How is joinablequeue used in multiprocessing queue?


Asked by Malik Lindsey on Dec 08, 2021 FAQ



JoinableQueue is used to make sure all elements stored in queue will be processed. 'task_done' is for worker to notify an element is done. 'q.join ()' will wait for all elements marked as done. With #2, there is no need to join wait for every worker. But it is important to join wait for every producer to store element into queue.
Accordingly,
Queue implements all the methods of Queue.Queue except for task_done () and join (). JoinableQueue, a Queue subclass, is a queue which additionally has task_done () and join () methods. Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
In this manner, If you use JoinableQueue then you must call JoinableQueue.task_done () for each task removed from the queue or else the semaphore used to count the number of unfinished tasks may eventually overflow, raising an exception. Based on the documentation, it's hard to be sure that Queue is actually empty.
Also,
In other words, Multiprocess queue is pretty slow putting and getting individual data, then QuickQueue wrap several data in one list, this list is one single data that is enqueue in the queue than is more quickly than put one individual data.
Subsequently,
This is an implementation of Quick Multiprocessing Queue for Python and work similar to multiprocessing.queue (more information about multiprocessing.queue in https://docs.python.org/3/library/multiprocessing.html?highlight=process#pipes-and-queues ). Last release version of the project to install in: https://pypi.org/project/quick_queue_project/