Mysql-how to end script execution before the PHP script times out

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.