The Python multiprocessing
module 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 were forked from a common parent process and, hence, can share the same RLock
object. However, for situations with independent processes (example: web server + cron job), one would need a named lock. Unfortunately, RLock()
does not accept a name argument for the lock. Is there a solution that allows to do something like this?
l = RLock('mylock')
l.acquire()
l.release()