-
-
Save elliotchance/3657633feb689051f5e456f7f5a5c622 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LockManager: | |
def __init__(self): | |
self.locks = [] | |
def add(self, transaction, record_id): | |
if not self.exists(transaction, record_id): | |
self.locks.append([transaction, record_id]) | |
def exists(self, transaction, record_id): | |
return any(lock[0] is transaction and lock[1] == record_id \ | |
for lock in self.locks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment