>>> import multiprocessing
>>> multiprocessing.Manager().Lock()
<thread.lock object at 0x7f64f7736290>
>>> type(multiprocessing.Lock())
<class 'multiprocessing.synchronize.Lock'>
Why the object produced by a manager is a thread.lock and not a multiprocessing.synchronize.Lock as it would be expected from a multiprocessing object?
Managed objects are always proxies; the goal of the manager is to make non-multiprocessing-aware objects into multiprocessing aware.
There is no point in doing this for multiprocessing.Lock() objects; these are implemented using semaphores and are fully multiprocessing capable without assistance.
threading.Lock on the other hand is not multiprocessing aware; there are some differences between threading.Lock() objects and multiprocessing.Lock(); the latter supports a timeout when acquiring a lock, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With