There are a lot of functions in my PHP script that call someone else's interface, but these interfaces are sometimes very slow, which will cause my script to time out and report "504 Gateway Time-out" on the page!
I want to abort the function that called the interface before the PHP script times out and return to the page with a hint, but I don't know how to know in advance that the script is about to expire.
Special Note: A function such as set time limit () is not used in my script.
Reply content:
There are a lot of functions in my PHP script that call someone else's interface, but these interfaces are sometimes very slow, which will cause my script to time out and report "504 Gateway Time-out" on the page!
I want to abort the function that called the interface before the PHP script times out and return to the page with a hint, but I don't know how to know in advance that the script is about to expire.
Special Note: A function such as set time limit () is not used in my script.
Using Gearman
Based on the description of the problem, guessing uses the Fsockopen function. If you are using the Fsockopen function, you can see the following connection http://us1.php.net/manual/en/function.stream-set-timeout.php