def config_cache_lock():
"""
Obtain the config cache lock, perform the code
in the context and then let the lock go.
:yield None
:return None:
"""
with open(conf().CONFIG_CACHE_LOCK, 'w+') as lock:
try:
log.debug(
"Getting config cache lock. "
"If this blocks forever, try deleting file "
"{} and restart the process.".format(conf().CONFIG_CACHE_LOCK)
)
flock(lock, LOCK_EX) # Blocks until lock becomes available
yield
finally:
log.debug("Releasing the config cache lock")
flock(lock, LOCK_UN)
评论列表
文章目录