lock icon indicating copy to clipboard operation
lock copied to clipboard

Check if the lock is taken

Open rhutanu90 opened this issue 7 years ago • 7 comments

Hi! We encountered a situation when we would like to terminate all the calls when a locked call is already in execution (instead of waiting). @malkusch do you plan to extend the library with this feature in the near future? :+1:

rhutanu90 avatar Jun 05 '18 15:06 rhutanu90

You mean, testing if the lock is taken, and then aborting?

willemstuursma avatar Jun 05 '18 18:06 willemstuursma

Same request here. I use predis locks. In some cases I don't want to wait until the lock is released, but abort the request if another process is already holding that lock.

TheLevti avatar Jun 06 '18 06:06 TheLevti

Yes, check if the lock is taken and if so throw an exception

rhutanu90 avatar Jun 06 '18 07:06 rhutanu90

I don't have any plans to add this feature. However, I'm willing to take in any pull requests that add this feature.

If you want to create a PR for this, please discuss the interface here first.

willemstuursma avatar Jun 06 '18 07:06 willemstuursma

If the Loop class had an ability to pass a flag to disable retries or set X retries instead of using timeout this could help this out etc.

tsmgeek avatar Jan 03 '20 13:01 tsmgeek

Hi. I would avoid to introduce a second timeout because funky things might happen. I would suggest the use of a flag to enable/disable the loop to execute more than once or till the locks ttl expire. Is this thread active or rather do you see value in this feature?

georgegg avatar Sep 21 '20 16:09 georgegg

"workaround", use Symfony Lock instead - https://symfony.com/doc/5.x/components/lock.html#usage

fredericgboutin-yapla avatar Mar 19 '24 17:03 fredericgboutin-yapla