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

Is it possible to set parameter for acquire? #67

Open
Twbadkid opened this issue Aug 26, 2019 · 5 comments
Open

Is it possible to set parameter for acquire? #67

Twbadkid opened this issue Aug 26, 2019 · 5 comments

Comments

@Twbadkid
Copy link

Hi,
In redis_lock/__init__.py line: 341

def __enter__(self):
    acquired = self.acquire(blocking=True)

blocking will always be True when we use cache.lock in with block,
Is it possible to set the parameter(blocking/timeout) from __init__ function or another function?

@ionelmc
Copy link
Owner

ionelmc commented Aug 26, 2019

So you would like this code:

with Lock(blocking=False):
    something

raise an exception and skip the something?

@ionelmc
Copy link
Owner

ionelmc commented Aug 26, 2019

An alternative api that doesn't mess with the __init__ could be:

with Lock().acquire_context(blocking=False):
    something

@Twbadkid
Copy link
Author

So you would like this code:

with Lock(blocking=False):
    something

raise an exception and skip the something?

Yes.
Is it possible to add any of these solutions in this library?

@tavor118sn
Copy link
Contributor

@ionelmc Any chance to implement this?
I can make a PR if you will review and merge

@ionelmc
Copy link
Owner

ionelmc commented Jul 8, 2022

@tavor118sn sure, please make that PR.

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

3 participants