Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frontend locking support #2

Open
MatthewScholefield opened this issue Jul 5, 2019 · 0 comments
Open

Add frontend locking support #2

MatthewScholefield opened this issue Jul 5, 2019 · 0 comments

Comments

@MatthewScholefield
Copy link
Member

Sometimes it's useful to use an index in the database as a lock:

events = db['events']
items = events['items']
with events['lock']:
    new_uuid = str(uuid4())
    if len(items) > 0:
        items[-1]['next_uuid'] = new_uuid
    items.append({'data': 'abc', 'next_uuid': None})

db['events']['lock'] would just be a bool and the request would wait for the bool to become false, change it to true, and then return, waiting for a followup request to set it back to false.

Alternatively, this could be generalized to a type of request that waits for a value to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant