"Infinite" timeout
Silex opened this issue · 2 comments
Hello,
Is there a way to make an infinite timeout? I have some tasks that can take hours, I don't want the lock to be released until it's finished :/
Also, maybe it wouldn't hurt to emphasize that you have to lock.release!
after your worker is done otherwise new workers won't aquire the lock until timeout is reached.
Hello.
Infinite lock idea kinda contradicts the reason why I wrote this gem ;-). You can try to set TTL to something pretty big, redis should handle it without a problem - something like a day 24 * 60 * 60 * 1000
seems to be working just fine.
Having infinite lock would be dangerous in case of a process crash, if you need to limit amount of workers running maybe you can have better luck with something more like https://github.com/brainopia/sidekiq-limit_fetch?
I will add release info in code example, didn't noticed I missed that, thanks :).
Heh, I'm already using sidekiq-limit_fetch
, it never occured to me that I could use it with a special queue that is limited to 1 worker to achieve "locking" :)
Maybe it is because I discovered it after sidekiq-lock? Anyway I'll reconsider my options, and I guess a high TTL is ok... I can always delete all offending lock keys when sidekiq starts.