Called reentrant / recursive lock (RLock) in Python
The Python module multiprocessing
has a class for reentrant / recursive locks:
from multiprocessing import RLock
l = RLock()
l.acquire()
l.acquire()
l.release()
l.release()
This works great for processes that have been decoupled from a common parent process and therefore may share the same object RLock
. However, for situations with independent processes (example: web server + cron job), a named lock is required . Unfortunately RLock()
does not accept a name argument to block. Is there a solution that allows you to do something like this?
l = RLock('mylock')
l.acquire()
l.release()
+3
source to share