Skip to content

Instantly share code, notes, and snippets.

@elliotchance
Created December 4, 2019 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotchance/3657633feb689051f5e456f7f5a5c622 to your computer and use it in GitHub Desktop.
Save elliotchance/3657633feb689051f5e456f7f5a5c622 to your computer and use it in GitHub Desktop.
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