(conn, lock_name, identifier)
| 33 | |
| 34 | |
| 35 | def release_lock(conn, lock_name, identifier): |
| 36 | pipe = conn.pipeline(True) |
| 37 | lock_name = LOCKER_PREFIX + lock_name |
| 38 | while True: |
| 39 | try: |
| 40 | pipe.watch(lock_name) |
| 41 | identifier_origin = pipe.get(lock_name).decode() |
| 42 | if identifier_origin == identifier: |
| 43 | pipe.multi() |
| 44 | pipe.delete(lock_name) |
| 45 | pipe.execute() |
| 46 | return True |
| 47 | pipe.unwatch() |
| 48 | break |
| 49 | |
| 50 | except redis.exceptions.WatchError: |
| 51 | pass |
| 52 | |
| 53 | return False |
no test coverage detected