There are many functions in my PHP script. These functions call others' interfaces, but these interfaces are sometimes slow, which causes my script to time out and report "504GatewayTime-out" on the page. I want to abort the functions that call interfaces before the PHP script times out and return them to the page...
There are many functions in my PHP script. These functions call other interfaces, but these interfaces are sometimes very slow, which causes my script to time out, "504 Gateway Time-out" is reported on the page.
I want to abort the functions that call the interface before the PHP script times out, and return a prompt to the page, but I don't know how to know in advance that the script is about to times out?
Note: set is not used in my script.TimeLimit.
Reply content:
There are many functions in my PHP script. These functions call other interfaces, but these interfaces are sometimes very slow, which causes my script to time out, "504 Gateway Time-out" is reported on the page.
I want to abort the functions that call the interface before the PHP script times out, and return a prompt to the page, but I don't know how to know in advance that the script is about to times out?
Note: set is not used in my script.TimeLimit.
Use Gearman
According to the problem description, I guess the fsockopen function will be used. If you are using the fsockopen function, you can refer to the following link http://us1.php.net/manual/en/function.stream-set-timeout.php