def release_lock(name):
"""
Release a lock for all. Note that the lock will be released even if it was
never acquired.
"""
# Note that in unit tests, and in case the wrapped code raises an
# IntegrityError, releasing the cache will result in a
# TransactionManagementError. This is because unit tests run inside atomic
# blocks. We cannot execute queries inside an atomic block if a transaction
# needs to be rollbacked.
try:
cache.delete(name)
except TransactionManagementError:
logger.error("Could not release lock %s", name)
评论列表
文章目录