-
Notifications
You must be signed in to change notification settings - Fork 78
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
Remove the force
arg from release()
#25
Comments
Two points:
|
Maybe we should just remove this |
Yes, that's what I'm proposing, also I propose to not track whether or not lock was held previously with |
Another point is that |
I like this idea. I'd still like it to raise exception, just like |
By exit codes I meant, that based on exit code from script method can raise exception or return successfully |
Good point. |
But should user be able to perform |
I think reset is a special case. It's by design "unsafe" - it's throwing away all the state after all ... we just document that it's unsafe and should not be used in normal cases. |
When reset was implemented initially it was for users that did a mess and forgot to properly release the locks. They needed a way to throw away all the locks (eg: after a machine crash, if they didn't use expires they need a way to have a "clean slate" on machine reboot) |
What if you need to extend a lock, that was held somewhere else? |
Another thing - what should |
The initial design was to have locks "id" as local state. IOW: "you lock it, you release it - it's your responsibility". If, say, there are users who need to lock a resource during a course of multiple processes then they should manually carry over the state of the lock (the "id"). They can easily do that by creating |
It's the same as if the lock wouldn't be acquired. You didn't lock it? You gotta get error cause there's something wrong in your code. |
In Python standard library there are |
As I understood it:
We could have an RLock object in redis-lock I suppose. Now I realize the current implementation is like |
Ok I think we're derailing a bit, going a bit back:
Agree on those? |
I don't see clear solution, I need some time to think. Maybe it's also time to ask other contributors about what they are thinking. |
Ok, so proposed new changes:
Anything against this @zoni @victor-torres @jweyrich ? |
It's seems fine to me, @ionelmc.
|
What about adding |
force
arg from release()
In the last comment I proposed to remove the |
Instead of removing |
What's wrong with having it raise exception instead? |
In my vision, it should work as you described, but also, when the methods invoked with |
There is What am I missing here? :) |
|
I think it's totally OK to ask users to actually have the proper id when doing the extend. |
So I've implemented the changes from #25 (comment) in #36 |
These changes will make couple of programming patterns be errors:
I'm not 100% on the last one tho ... |
The reasoning for "acquire on lock with given id is error" (eg:
Let me know if I missed something. |
Nice. |
@ionelmc This makes impossible to use the same lock from different processes, like described in the #25 (comment) by @victor-torres. |
lock.id On Friday, 19 February 2016, Andrew Pashkin notifications@github.com
Thanks, |
@ionelmc Indeed, I thought there is no public interface for that. |
@ionelmc, what do you think about my first comment? I propose to remove that limitation. It will free user from requirement of having some sort of messaging for sharing actual lock id. |
Not really sure what's being proposed here. Are you suggesting to remove the id completely? Then we don't have any way to protect from programming errors like: releasing what you didn't acquire, releasing expired lock, extending lock that isn't acquired by you and so on. |
No, I'm proposing to not treat lock as held if user just provided an |
Hmmm. It could work. Could be check in |
I think it's better to make a dedicated method for testing if lock is held. In my practice I had a case when I needed to make such tests and I just did |
Ok but in this situation we'd have two kinds of "check if it's held":
(1) would be new here |
I think now, that it would be good to reproduce how it's done in |
I think, |
|
I like this idea. |
@ionelmc, what do you think about |
I still need to think about it. But on first look RLock on't make sense because we don't have any "counter". Not sure how this would be implemented, or if it's possible:
|
What RLock (and the cite) have to do with a counter? |
As I understood it, you have to know how many times you acquired the lock. How do you interpret this?
|
Indeed, you're right, I never used recursive aspect of |
My point is, that in different cases, different properties of synchronization mechanisms are needed, such as recursiveness or ability to be owned by a process. And for that, it is good to have different types of locks - recursive ownership-aware lock, recursive non-ownership-aware, etc. |
I'm open to concrete proposals. BTW, shouldn't we have a different issue for sketching this out? |
Sounds good 👍 |
or something similar, eg:
The text was updated successfully, but these errors were encountered: