The main task of multi-threaded applications is the coordination of threads that share data or other resources. To this end, a multi-threaded module provides a number of synchronization primitives, including locks, events, state variables, and semaphores.
Although these tools are powerful, minor design errors can lead to problems that are difficult to reproduce. So, the preferred approach to the coordination task is to concentrate all access to the resource in one stream, and then use the queue module to submit this stream with requests from other flows. Using Applications Queue.Queue objects for cross-thread communication and coordination are easier to design, more readable, and more reliable.
This basically indicates the use of Queue.Queue for inter-thread communication and coordination instead of powerful tools like semaphores, locks, etc.
My question is, what is the disadvantage of the proposed method? When to use more “powerful tools" and why?
Edit
To be clear, I know what semaphores are. I'm just wondering why the Python documentation suggests using the Queue.Queue method instead of the “powerful tools” - I just use my own documentation without coming up with my own.
source share