I have a script that takes 3 to 4 minute to execute. I want to call this script on cron call. I already use this in my cron but i got some error. My script give the correct output. But i got this error. when my script executed.
Uncaught coding_exception: Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
Code should look like:
$factory = \core\lock\lock_config::get_lock_factory('type');
$lock = $factory->get_lock(Resource id #956);
$lock->release(); // Locks must ALWAYS be released like this.
what is the issue with it.Please help and give me some suggestion.
Thank you so much for reply Tomek,
I have checked my script with various way to executed like url, crontab (Linux). In the both case my script take time 3-4 minute due to some our requirement. But i didn't find any exception or error. I changed my script web to cli and run it using crontab. i do not find any error and exception and its work fine. That's also not interrupt the Moodle cron process.
Is that right way to do? Please suggest.
Is execution time taken by the script is the issue? If we call it on Moodle cron function.
Please give me some suggestion so i can investigate more.
Thanks for valuable suggestion Andreas,
I must implement your suggestion.
Yes u r right. In the beginning , i have created it on cron function . Then when cron is executed then its give an error that i was mention in the above post. Then I change it into the cli script and run through crontab.
You mean it Moodle schedule task?
Can you provide more information on your script to help us? Perhaps you can share it?
It sounds like you've written a CLI script, and that CLI script either obtains a lock itself, or it uses an API which obtains a lock. It also appears that you are either not releasing that lock properly, or it is exiting before you do so.
I suspect that you are using an API somewhere which is not intended to be globally consumed, or which has a counterpart to release the lock.
If you can provide more information then we may be able to help.
I wrote a cron function in my plugin . But when Moodle cron runs its gives errors as i mention on my question on above of the post. My function take 3-4 minute execute. Its a multiple function and loops calls that is why its take so much time to execute.
After this issue, i changed my script into a cli script and its working fine. But for this script i need to setup crontab (Linux).
I hope you understand my problem. I want to implement solution according to Moodle without setting our own crontab for one script.