Locks & Reentrant Lock

This lesson discusses the Lock and Reentrant Lock versions of the multiprocessing module.

We'll cover the following...

Locks & Reentrant Lock

Similar to the threading module, synchronization primitives exist for the multiprocessing module to coordinate among multiple processes. The primitives between the two modules have a lot of commonalities.

Because of the similarities, we just reproduce the examples from the threading section using the primitives from the multiprocessing module.

Lock

Lock is a non-recursive object and shares the same DNA as the threading.Lock class. In the section on using Queues and Pipes we introduced a snippet with a bug, that could potentially hang depending on the order in which the two processes consumed objects placed on the queue. We can change that ...