gpt4 book ai didi

php - 计算和处理php脚本进程的运行时间

转载 作者:行者123 更新时间:2023-12-03 08:14:27 26 4
gpt4 key购买 nike

我有一些我知道在某些时候会达到最大超时的代码。

我尝试使用try-catch来处理此错误,但我刚刚被告知无法以这种方式捕获超时。

有没有一种方法可以捕获错误,或者计算处理时间并在错误超时之前处理错误?

最佳答案

正如iTom正确提到的那样,首先您需要弄清楚为什么您的代码要花费30秒。

如果可以预期,并且您正在对数据库更新进行某种形式的处理,那么在drupal中,我们已准备好处理此问题。您需要使用 Drupal批处理API

在这里查看更多详细信息:https://api.drupal.org/api/drupal/includes!form.inc/group/batch/7

Functions allowing forms processing to be spread out over several page requests, thus ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations.

关于php - 计算和处理php脚本进程的运行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17494830/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com