Reputation: 47
I have a php file which I think the code doesn't matter.
The problem is that I cannot allow it to run more than 3 times at a time since it makes many requests to the mysql database and becomes saturated.
I've seen some traffic light in php but I don't like it.
Do you have any better ideas?
Thank you.
Upvotes: 1
Views: 112
Reputation: 6737
These are some approach you can follow to achieve your goal:
To handle the case in which the script may fail during its execution, you may insert a try...catch
block and delete the file in the finally
clause:
try
{
// create the file
// script work
}
catch(Exception $e)
{
// handle the exception, e.g.:
echo 'Caught exception: ', $e->getMessage(), "\n";
}
finally
{
// delete the file
}
Upvotes: 1