I’m creating a script that reads a Wikipedia article, and then does some processing. I’m accessing the article contents with cURL. The problem is, sometimes the cURL request times out, particularly on large articles. As the server this script will be run on only allows a maximum of 30 seconds to timeout, this is an issue.
The only workaround I can think of would be–should a particular line of code approach the timeout limit–killing the function and running something else. This would be a decent solution to the problem for my purposes. The problem is, I don’t know that this is possible to do.
Is it? If not, are there any other workarounds for timing-out cURL requests?
This should kill your curl function 10 seconds before the PHP script dies: