synchronization - named reentrant/recursive lock (RLock) in Python -
the python multiprocessing
module has class reentrant/recursive locks:
from multiprocessing import rlock l = rlock() l.acquire() l.acquire() l.release() l.release()
this works great processes forked common parent process and, hence, can share same rlock
object. however, situations independent processes (example: web server + cron job), 1 need named lock. unfortunately, rlock()
not accept name argument lock. there solution allows this?
l = rlock('mylock') l.acquire() l.release()
check out oslo_concurrency.lockutils
. has lock
context manager , synchronized
decorator, both of take name , other handy interprocess-friendly parameters.
Comments
Post a Comment