Celery: upgrade `memcache_lock` with latest code from docs
@@ -94,8 +94,9 @@ def memcache_lock(lock_id, oid):
finally:
# memcache delete is very slow, but we have to use it to take
# advantage of using add() for atomic locking
- if monotonic() < timeout_at:
+ if monotonic() < timeout_at and status:
# don't release the lock if we exceeded the timeout
# to lessen the chance of releasing an expired lock
- # owned by someone else.
+ # owned by someone else
+ # also don't release the lock if we didn't acquire it
cache.delete(lock_id)
