1

To quote from an answer in Lock, mutex, semaphore... what's the difference?

A lock allows only one thread to enter the part that's locked and the lock is not shared with any other processes.

A mutex is the same as a lock but it can be system wide (shared by multiple processes).

A semaphore does the same as a mutex but allows x number of threads to en

This is what I'm confused about: multiprocessing does fork/spawn new processes, right? So even though multiprocessing.Lock is called "lock", is it not really a lock but a mutex or semaphore?

finefoot
  • 9,914
  • 7
  • 59
  • 102
  • Like you can read in documentation - `multiprocessing.Lock` works across multi processes and threads but traditional https://docs.python.org/3/library/threading.html#threading.Lock works across threads within one process so indeed, `multiprocessing.Lock` works like mutex. This is only name convetion. – pawelbylina Sep 25 '19 at 08:51
  • Also keep in mind, that multiprocessing was designed to resemble the threading API; accurate terminology might have been sacrificed for that design goal in some cases. That being said, I don't agree with the quoted definition that the threads synchronizing via a lock must belong to the same process. – shmee Sep 25 '19 at 09:09

0 Answers0