August 2015
Intermediate to advanced
286 pages
5h 42m
English
As discussed earlier, threading can be complicated when threads need to share data or resources. As we saw, the Python threading module provides many synchronization primitives, including semaphores, condition variables, events, and locks. While these options exist, it is considered a best practice to instead concentrate on using the module queue. Queues are much easier to deal with and make threaded programming considerably safer, as they effectively funnel all access to a resource of a single thread and allow a cleaner and more readable design pattern.
We will simply consider these four queue methods:
put(): This puts an item in the queueget(): This removes and returns an item from the queuetask_done(): This ...Read now
Unlock full access