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

Proposal for shortcuts #37

Open
maxpoletaev opened this issue Jun 28, 2017 · 0 comments
Open

Proposal for shortcuts #37

maxpoletaev opened this issue Jun 28, 2017 · 0 comments

Comments

@maxpoletaev
Copy link

maxpoletaev commented Jun 28, 2017

Writing something like this:

with NonBlockingLock.objects.acquire_lock(lock_name='update_user_' + str(user.id)):
    pass

...is too hard for me.
I think we can made API more shorter and pretty. In my vision it could be function which accepts lock_name argument and returns context manager, decorator or Lock instance.

from locking import db_locking

def update_user(request):
    with db_locking.lock('update_user'):
        pass

@db_locking.lock('update_user')
def update_user(request):
    pass

def update_user(request):
    lock = db_locking.lock('update_user')
    lock.acquire()
    lock.release()

What you think?

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

No branches or pull requests

1 participant