0

I am trying to improve a batch function so that it uses lock_acquire(), in order to prevent users from trying to run a large batch if it is already running.

To do this, I try getting the lock in the module_batch_update_users function that returns the batch definition, and releasing the lock in the module_batch_update_users_finished function. I am not sure if there is a better way to do this.

Unfortunately, when run via Drush, if the user presses Ctrl+C the command is interrupted, and the lock is not released. I would have to wait until it expires.

Is there a better way to do this, or a way to detect when the command terminates abruptly in order to release the lock?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.